Using COM Object Invalid Pointer Error
-
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.....
-
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.....
-
Ash_VCPP wrote:
SCRIPTOBJLib::IScriptObjPtr sobj; //sobj->QueryInterface(IId_,void* &vp);
You have not initialized
sobj
to an instance of anything.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.....
-
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.....
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 ofSCRIPTOBJLib::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. -
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 ofSCRIPTOBJLib::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.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.....
-
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.....
-
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.....
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.
-
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.
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.....
-
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.....
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.