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. C / C++ / MFC
  4. Using COM Object Invalid Pointer Error

Using COM Object Invalid Pointer Error

Scheduled Pinned Locked Moved C / C++ / MFC
comhelp
9 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.....

    L J 2 Replies 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.....

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

      Ash_VCPP wrote:

      SCRIPTOBJLib::IScriptObjPtr sobj; //sobj->QueryInterface(IId_,void* &vp);

      You have not initialized sobj to an instance of anything.

      A 1 Reply Last reply
      0
      • L Lost User

        Ash_VCPP wrote:

        SCRIPTOBJLib::IScriptObjPtr sobj; //sobj->QueryInterface(IId_,void* &vp);

        You have not initialized sobj to an instance of anything.

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

        Yes but i tried many ways as you can see it in commented code to initialize it, but getting error HRESULT value= -2147221164. can you please suggest me how can i initialize com object with example regards of my code.

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

        L 1 Reply Last reply
        0
        • A Ash_VCPP

          Yes but i tried many ways as you can see it in commented code to initialize it, but getting error HRESULT value= -2147221164. can you please suggest me how can i initialize com object with example regards of my code.

          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

          Ash_VCPP wrote:

          can you please suggest me how can i initialize com object with example regards of my code.

          You have the following declaration in your code

          SCRIPTOBJLib::IScriptObjPtr sobj;

          So you need to initialize sobj to an instance of SCRIPTOBJLib::IScriptObjPtr. The documentation should explain how to do this. If you do not understand instances of classes I suggest you refer back to he C++ documentation for guidance.

          A 1 Reply Last reply
          0
          • L Lost User

            Ash_VCPP wrote:

            can you please suggest me how can i initialize com object with example regards of my code.

            You have the following declaration in your code

            SCRIPTOBJLib::IScriptObjPtr sobj;

            So you need to initialize sobj to an instance of SCRIPTOBJLib::IScriptObjPtr. The documentation should explain how to do this. If you do not understand instances of classes I suggest you refer back to he C++ documentation for guidance.

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

            But i think initializing COM object is different from normal class, and if not then can you please show me few lines of code to initialize COM object, Because i am wondering with google since last two dyas.

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

            L 1 Reply Last reply
            0
            • A Ash_VCPP

              But i think initializing COM object is different from normal class, and if not then can you please show me few lines of code to initialize COM object, Because i am wondering with google since last two dyas.

              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
              #6

              As I said in my previous entry you need to use the documentation; I have not used the library that you are working with. Perhaps some time reading through some of the COM articles here on CodeProject would be time well spent.

              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.....

                J Offline
                J Offline
                Jeff Archer
                wrote on last edited by
                #7

                The HRESULT you have indicated is 0x80040152 - Could not find the key in the registry Sounds like the COM object you are trying to use is not correctly installed or you are not using the correct ProgID. Try using a CLASSID for your CreateInstance.

                A 1 Reply Last reply
                0
                • J Jeff Archer

                  The HRESULT you have indicated is 0x80040152 - Could not find the key in the registry Sounds like the COM object you are trying to use is not correctly installed or you are not using the correct ProgID. Try using a CLASSID for your CreateInstance.

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

                  Hi Jeff, I think the helpstring which we pass in idl file will be the progID please let me know if i am wrong,So here i am using below line to get the class id:- HRESULT hres1 = CLSIDFromProgID(OLESTR("ScriptObj 1.0 Type Library"), &clsid); But still i am getting the same error.I have seen registry entry for my dll and its there with the string i mentioned in above function.Please provide me some suggestions on this.

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

                  J 1 Reply Last reply
                  0
                  • A Ash_VCPP

                    Hi Jeff, I think the helpstring which we pass in idl file will be the progID please let me know if i am wrong,So here i am using below line to get the class id:- HRESULT hres1 = CLSIDFromProgID(OLESTR("ScriptObj 1.0 Type Library"), &clsid); But still i am getting the same error.I have seen registry entry for my dll and its there with the string i mentioned in above function.Please provide me some suggestions on this.

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

                    J Offline
                    J Offline
                    Jeff Archer
                    wrote on last edited by
                    #9

                    If the return from this is 0x80040152 it is not being found in the registry.   I suggest try the class id just as the next step of investigation.   This HRESULT is either the client not registered correctly or using the incorrect ProdID.

                    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