CoCreateInstance Problem & GetLastError 0x0000007e
-
Hi All I have this call to CoCreateInstance that fails, and i get 0x0000007e from GetLastError. Has everybody allready had this kind of error ? Thank you. // import VoipTestCom.dll #pragma warning(disable:4146) #import "C:\workvs2008\binaries\Win32\Release\bin\VoipTestCom.dll" raw_interfaces_only, raw_native_types, no_namespace, named_guids LRESULT CSTapiCom::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { ISimpleClientPtr m_sipclicom; CAxWindow wnd; CLSID clsid; LPUNKNOWN pUnkCtrl, pUnkCont; HRESULT hr = CLSIDFromProgID(OLESTR("VoipTestCom.SimpleClient"), &clsid); if (hr == S_OK ) { ::MessageBox(NULL, _T("CLSIDFromProgID...ok"), _T("INFO"), MB_OK); } hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown, (void**)&pUnkCtrl); if (hr == S_OK ) { ::MessageBox(NULL, _T("CoCreateInstance...ok"), _T("INFO"), MB_OK); } else { TCHAR szBuff[64]; swprintf(szBuff, L"CoCreateInstance...fail->%x",GetLastError()); ::MessageBox(NULL, szBuff, _T("INFO"), MB_OK); } return TRUE; }
-
i get 0x0000007e from GetLastError
-
i get 0x0000007e from GetLastError
-
Hi All I have this call to CoCreateInstance that fails, and i get 0x0000007e from GetLastError. Has everybody allready had this kind of error ? Thank you. // import VoipTestCom.dll #pragma warning(disable:4146) #import "C:\workvs2008\binaries\Win32\Release\bin\VoipTestCom.dll" raw_interfaces_only, raw_native_types, no_namespace, named_guids LRESULT CSTapiCom::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { ISimpleClientPtr m_sipclicom; CAxWindow wnd; CLSID clsid; LPUNKNOWN pUnkCtrl, pUnkCont; HRESULT hr = CLSIDFromProgID(OLESTR("VoipTestCom.SimpleClient"), &clsid); if (hr == S_OK ) { ::MessageBox(NULL, _T("CLSIDFromProgID...ok"), _T("INFO"), MB_OK); } hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown, (void**)&pUnkCtrl); if (hr == S_OK ) { ::MessageBox(NULL, _T("CoCreateInstance...ok"), _T("INFO"), MB_OK); } else { TCHAR szBuff[64]; swprintf(szBuff, L"CoCreateInstance...fail->%x",GetLastError()); ::MessageBox(NULL, szBuff, _T("INFO"), MB_OK); } return TRUE; }
The obvious question is: did you initialise COM?
Steve
-
According to the documentation[^] that is equivalent to
ERROR_MOD_NOT_FOUND
which means it cannot find the file containing the COM class.Use the best guess
Here is the VoipTestCom_i.c & VoipTestCom.idl code I used to call the object. The object is nammed SimpleClient and the method I call is nammed TestOnRegisterStatusChanged(). I want to use ATL component into my Composite Control(CYHtapiCom) in C++ with ATL. When i test this code on my atl control. I am getting the error: CoCreateInstance failed 0x0000007e. How to add VoipTestCom controls to an ATL composite control programmatically in Visual C++? Thank you. 1. LRESULT CYHtapiCom::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { CAxWindow wnd; CLSID clsid; LPUNKNOWN pUnkCtrl, pUnkCont; HRESULT hr = CLSIDFromProgID(OLESTR("VoipTestCom.SimpleClient"), &clsid); hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown, (void**)&pUnkCtrl); CComQIPtr spPerStm(pUnkCtrl); spPerStm->InitNew(); wnd.Attach(m_hWnd); wnd.AttachControl(pUnkCtrl, &pUnkCont); return TRUE; } 2.VoipTestCom_i.c /* this ALWAYS GENERATED file contains the IIDs and CLSIDs */ /* link this file in with the server and any clients */ /* File created by MIDL compiler version 7.00.0500 */ /* at Sat Apr 06 21:40:37 2013 */ /* Compiler settings for .\VoipTestCom.idl: Oicf, W1, Zp8, env=Win32 (32b run) protocol : dce , ms_ext, c_ext, robust error checks: stub_data VC __declspec() decoration level: __declspec(uuid()), __declspec(selectany), __declspec(novtable) DECLSPEC_UUID(), MIDL_INTERFACE() */ //@@MIDL_FILE_HEADING( ) #pragma warning( disable: 4049 ) /* more than 64k source lines */ #ifdef __cplusplus extern "C"{ #endif #include #include #ifdef _MIDL_USE_GUIDDEF_ #ifndef INITGUID #define INITGUID #include #undef INITGUID #else #include #endif #define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) #else // !_MIDL_USE_GUIDDEF_ #ifndef __IID_DEFINED__ #define __IID_DEFINED__ typedef struct _IID { unsigned long x; unsigned short s1; unsigned short s2; unsigned char c[8]; } IID; #endif // __IID_DEFINED__ #ifndef CLSID_DEFINED #define CLSID_DEFINED typedef IID CLSID; #endif // CLSID_DEFINED #define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} #endif !_MIDL_USE_GUIDDEF_ MIDL_DEFINE_GUID(IID, IID_ISimpleClient,0x5CA1C162,0x671E,0x4EE8,0x98,0x75,0x27,0x7F,0x4E,0xF1,0xE8,0xCE); MIDL_DEFINE_GUID(I
-
The obvious question is: did you initialise COM?
Steve
CoInitialize? Where do I add the CoInitialize?
-
CoInitialize? Where do I add the CoInitialize?
Somewhere before you use COM.
Steve
-
Here is the VoipTestCom_i.c & VoipTestCom.idl code I used to call the object. The object is nammed SimpleClient and the method I call is nammed TestOnRegisterStatusChanged(). I want to use ATL component into my Composite Control(CYHtapiCom) in C++ with ATL. When i test this code on my atl control. I am getting the error: CoCreateInstance failed 0x0000007e. How to add VoipTestCom controls to an ATL composite control programmatically in Visual C++? Thank you. 1. LRESULT CYHtapiCom::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { CAxWindow wnd; CLSID clsid; LPUNKNOWN pUnkCtrl, pUnkCont; HRESULT hr = CLSIDFromProgID(OLESTR("VoipTestCom.SimpleClient"), &clsid); hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown, (void**)&pUnkCtrl); CComQIPtr spPerStm(pUnkCtrl); spPerStm->InitNew(); wnd.Attach(m_hWnd); wnd.AttachControl(pUnkCtrl, &pUnkCont); return TRUE; } 2.VoipTestCom_i.c /* this ALWAYS GENERATED file contains the IIDs and CLSIDs */ /* link this file in with the server and any clients */ /* File created by MIDL compiler version 7.00.0500 */ /* at Sat Apr 06 21:40:37 2013 */ /* Compiler settings for .\VoipTestCom.idl: Oicf, W1, Zp8, env=Win32 (32b run) protocol : dce , ms_ext, c_ext, robust error checks: stub_data VC __declspec() decoration level: __declspec(uuid()), __declspec(selectany), __declspec(novtable) DECLSPEC_UUID(), MIDL_INTERFACE() */ //@@MIDL_FILE_HEADING( ) #pragma warning( disable: 4049 ) /* more than 64k source lines */ #ifdef __cplusplus extern "C"{ #endif #include #include #ifdef _MIDL_USE_GUIDDEF_ #ifndef INITGUID #define INITGUID #include #undef INITGUID #else #include #endif #define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) #else // !_MIDL_USE_GUIDDEF_ #ifndef __IID_DEFINED__ #define __IID_DEFINED__ typedef struct _IID { unsigned long x; unsigned short s1; unsigned short s2; unsigned char c[8]; } IID; #endif // __IID_DEFINED__ #ifndef CLSID_DEFINED #define CLSID_DEFINED typedef IID CLSID; #endif // CLSID_DEFINED #define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} #endif !_MIDL_USE_GUIDDEF_ MIDL_DEFINE_GUID(IID, IID_ISimpleClient,0x5CA1C162,0x671E,0x4EE8,0x98,0x75,0x27,0x7F,0x4E,0xF1,0xE8,0xCE); MIDL_DEFINE_GUID(I
-
CoInitialize? Where do I add the CoInitialize?
-
Somewhere before you use COM.
Steve
LRESULT CYHtapiCom::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { CAxWindow wnd; CLSID clsid; LPUNKNOWN pUnkCtrl, pUnkCont; HRESULT hr = CLSIDFromProgID(OLESTR("VoipTestCom.SimpleClient"), &clsid); hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown, (void**)&pUnkCtrl); CComQIPtr spPerStm(pUnkCtrl); spPerStm->InitNew(); wnd.Attach(m_hWnd); wnd.AttachControl(pUnkCtrl, &pUnkCont); return TRUE; }