Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Using COM component invalid pointer error

Using COM component invalid pointer error

Scheduled Pinned Locked Moved COM
comhelp
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ash_VCPP
    wrote on last edited by
    #1

    Hi All, I have created COM component(dll) and created one client to use it, Please finnd the code of client:-

    HRESULT hr = CoInitialize(0); //CoCreateInstance( SCRIPTOBJLib::IScriptObjPtr sobj; //sobj->QueryInterface(IId_,void* &vp); //HRESULT hRes = CComObject<CScriptObj>::CreateInstance(&sobj); //CreateInstance(NULL,IID_IUnknown,(void*)&vp); //HRESULT hres = sobj.CreateInstance ( __uuidof(SCRIPTOBJLib::IScriptObj) ); //HRESULT hres = sobj.CreateInstance("ScriptObj 1.0 Type Library"); //at this point i am getting the error sobj->SetLanguage((unsigned short *)"VBScript"); CoUninitialize();

    Please give me some solutions coz i tried every possible way.

    Thanks A Ton Ash_VCPP walking over water is just knowing where the stones are.....

    K 1 Reply Last reply
    0
    • A Ash_VCPP

      Hi All, I have created COM component(dll) and created one client to use it, Please finnd the code of client:-

      HRESULT hr = CoInitialize(0); //CoCreateInstance( SCRIPTOBJLib::IScriptObjPtr sobj; //sobj->QueryInterface(IId_,void* &vp); //HRESULT hRes = CComObject<CScriptObj>::CreateInstance(&sobj); //CreateInstance(NULL,IID_IUnknown,(void*)&vp); //HRESULT hres = sobj.CreateInstance ( __uuidof(SCRIPTOBJLib::IScriptObj) ); //HRESULT hres = sobj.CreateInstance("ScriptObj 1.0 Type Library"); //at this point i am getting the error sobj->SetLanguage((unsigned short *)"VBScript"); CoUninitialize();

      Please give me some solutions coz i tried every possible way.

      Thanks A Ton Ash_VCPP walking over water is just knowing where the stones are.....

      K Offline
      K Offline
      KarstenK
      wrote on last edited by
      #2

      your code isnt readable. :wtf: What are the error codes? Google them

      Press F1 for help or google it. Greetings from Germany

      A 1 Reply Last reply
      0
      • K KarstenK

        your code isnt readable. :wtf: What are the error codes? Google them

        Press F1 for help or google it. Greetings from Germany

        A Offline
        A Offline
        Ash_VCPP
        wrote on last edited by
        #3

        Hi KarstenK, I am getting value of hresult= -2147221164 Please find the code below: HRESULT hr = CoInitialize(0); //CoCreateInstance( SCRIPTOBJLib::IScriptObjPtr sobj; //sobj->QueryInterface(IId_,void* &vp); //HRESULT hRes = CComObject<CScriptObj>::CreateInstance(&sobj); //CreateInstance(NULL,IID_IUnknown,(void*)&vp); HRESULT hres = sobj.CreateInstance ( __uuidof(SCRIPTOBJLib::IScriptObj) ); //HRESULT hres = sobj.CreateInstance("ScriptObj 1.0 Type Library"); sobj->SetLanguage((unsigned short *)"VBScript"); CoUninitialize();

        Thanks A Ton Ash_VCPP walking over water is just knowing where the stones are.....

        L K 2 Replies Last reply
        0
        • A Ash_VCPP

          Hi KarstenK, I am getting value of hresult= -2147221164 Please find the code below: HRESULT hr = CoInitialize(0); //CoCreateInstance( SCRIPTOBJLib::IScriptObjPtr sobj; //sobj->QueryInterface(IId_,void* &vp); //HRESULT hRes = CComObject<CScriptObj>::CreateInstance(&sobj); //CreateInstance(NULL,IID_IUnknown,(void*)&vp); HRESULT hres = sobj.CreateInstance ( __uuidof(SCRIPTOBJLib::IScriptObj) ); //HRESULT hres = sobj.CreateInstance("ScriptObj 1.0 Type Library"); sobj->SetLanguage((unsigned short *)"VBScript"); CoUninitialize();

          Thanks A Ton Ash_VCPP walking over water is just knowing where the stones are.....

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I think that the issue is that you are using getting the ID of the interface: __uuidof(SCRIPTOBJLib::IScriptObj) You need the ID of the coclass in the CreateInstance call. It is probably __uuidof(SCRIPTOBJLib::ScriptObj) depending on how the object has been implemented.

          A 1 Reply Last reply
          0
          • L Lost User

            I think that the issue is that you are using getting the ID of the interface: __uuidof(SCRIPTOBJLib::IScriptObj) You need the ID of the coclass in the CreateInstance call. It is probably __uuidof(SCRIPTOBJLib::ScriptObj) depending on how the object has been implemented.

            A Offline
            A Offline
            Ash_VCPP
            wrote on last edited by
            #5

            But from the library i am getting two things: 1.IScriptObj 2.IScriptObjptr So what else i can try.

            Thanks A Ton Ash_VCPP walking over water is just knowing where the stones are.....

            1 Reply Last reply
            0
            • A Ash_VCPP

              Hi KarstenK, I am getting value of hresult= -2147221164 Please find the code below: HRESULT hr = CoInitialize(0); //CoCreateInstance( SCRIPTOBJLib::IScriptObjPtr sobj; //sobj->QueryInterface(IId_,void* &vp); //HRESULT hRes = CComObject<CScriptObj>::CreateInstance(&sobj); //CreateInstance(NULL,IID_IUnknown,(void*)&vp); HRESULT hres = sobj.CreateInstance ( __uuidof(SCRIPTOBJLib::IScriptObj) ); //HRESULT hres = sobj.CreateInstance("ScriptObj 1.0 Type Library"); sobj->SetLanguage((unsigned short *)"VBScript"); CoUninitialize();

              Thanks A Ton Ash_VCPP walking over water is just knowing where the stones are.....

              K Offline
              K Offline
              KarstenK
              wrote on last edited by
              #6

              Please use for HRESULT hexadecimal values (Just do it! if you want to run COM) if you google that (-2147221164 => hex 80040154) you find things like "class not registered". This means that SCRIPTOBJLib::IScriptObj isnt registered properly. ->regsvr32

              Press F1 for help or google it. Greetings from Germany

              L 1 Reply Last reply
              0
              • K KarstenK

                Please use for HRESULT hexadecimal values (Just do it! if you want to run COM) if you google that (-2147221164 => hex 80040154) you find things like "class not registered". This means that SCRIPTOBJLib::IScriptObj isnt registered properly. ->regsvr32

                Press F1 for help or google it. Greetings from Germany

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                I note the poster has two threads going on this question, one here and one in the C++ forum. I have now bowed out.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups