COM unable to obtain interface -
-
I have some COM client code that I am trying to write
IAdd \*pAdd = NULL ; IClassFactory \*pClassFactory= NULL ; IUnknown \*pUnknown = NULL ; if (SUCCEEDED(CoInitializeEx(NULL, COINIT\_APARTMENTTHREADED))) { HRESULT res = CoCreateInstance(g\_MotAutoplaycfgCLSID , NULL , CLSCTX\_ALL , IID\_IUnknown , (void \*\*)&pUnknown); //res = pUnknown->QueryInterface(IID\_IAdd , (void \*\*)pAdd); res = CoGetClassObject(g\_MotAutoplaycfgCLSID , CLSCTX\_ALL , NULL , IID\_IClassFactory , (void \*\*)pClassFactory ); if(res == E\_NOINTERFACE ) { int x = 1; } else if(res == E\_INVALIDARG) { int r = GetLastError() ; } }
I can get this to retrive a valid pointer for pUnknown
HRESULT res = CoCreateInstance(g\_MotAutoplaycfgCLSID , NULL , CLSCTX\_ALL , IID\_IUnknown , (void \*\*)&pUnknown);
However I am unable to obtain the interface Handle to IAdd Interface. On the Server Side I can see that the ClassFactory class is created and that the Coclass is also instantiated. Help is appreciated
Engineering is the effort !
-
I have some COM client code that I am trying to write
IAdd \*pAdd = NULL ; IClassFactory \*pClassFactory= NULL ; IUnknown \*pUnknown = NULL ; if (SUCCEEDED(CoInitializeEx(NULL, COINIT\_APARTMENTTHREADED))) { HRESULT res = CoCreateInstance(g\_MotAutoplaycfgCLSID , NULL , CLSCTX\_ALL , IID\_IUnknown , (void \*\*)&pUnknown); //res = pUnknown->QueryInterface(IID\_IAdd , (void \*\*)pAdd); res = CoGetClassObject(g\_MotAutoplaycfgCLSID , CLSCTX\_ALL , NULL , IID\_IClassFactory , (void \*\*)pClassFactory ); if(res == E\_NOINTERFACE ) { int x = 1; } else if(res == E\_INVALIDARG) { int r = GetLastError() ; } }
I can get this to retrive a valid pointer for pUnknown
HRESULT res = CoCreateInstance(g\_MotAutoplaycfgCLSID , NULL , CLSCTX\_ALL , IID\_IUnknown , (void \*\*)&pUnknown);
However I am unable to obtain the interface Handle to IAdd Interface. On the Server Side I can see that the ClassFactory class is created and that the Coclass is also instantiated. Help is appreciated
Engineering is the effort !
You can use pUnknown->QueryInterface(.. , IAdd, ....) Tarmo.
-
I have some COM client code that I am trying to write
IAdd \*pAdd = NULL ; IClassFactory \*pClassFactory= NULL ; IUnknown \*pUnknown = NULL ; if (SUCCEEDED(CoInitializeEx(NULL, COINIT\_APARTMENTTHREADED))) { HRESULT res = CoCreateInstance(g\_MotAutoplaycfgCLSID , NULL , CLSCTX\_ALL , IID\_IUnknown , (void \*\*)&pUnknown); //res = pUnknown->QueryInterface(IID\_IAdd , (void \*\*)pAdd); res = CoGetClassObject(g\_MotAutoplaycfgCLSID , CLSCTX\_ALL , NULL , IID\_IClassFactory , (void \*\*)pClassFactory ); if(res == E\_NOINTERFACE ) { int x = 1; } else if(res == E\_INVALIDARG) { int r = GetLastError() ; } }
I can get this to retrive a valid pointer for pUnknown
HRESULT res = CoCreateInstance(g\_MotAutoplaycfgCLSID , NULL , CLSCTX\_ALL , IID\_IUnknown , (void \*\*)&pUnknown);
However I am unable to obtain the interface Handle to IAdd Interface. On the Server Side I can see that the ClassFactory class is created and that the Coclass is also instantiated. Help is appreciated
Engineering is the effort !
What is the error you get?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
What is the error you get?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain ClarkeI was able to modify my client code to do this
if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
{HRESULT res = CoGetClassObject(g\_MycfgCLSID , CLSCTX\_ALL , NULL , IID\_IClassFactory , (void \*\*)&pClassFactory ); if(SUCCEEDED(res)) { // res = pUnknown->QueryInterface(IID\_IAdd,(void \*\*)&pAdd); res = pClassFactory->CreateInstance(0,IID\_IAdd , (void \*\*)&pAdd); pClassFactory->Release(); } else if(res == E\_NOINTERFACE ) { int x = 1; } else if(res == E\_INVALIDARG) { int r = GetLastError() ; } CoUninitialize(); }
The call to
HRESULT res = CoGetClassObject(g_MycfgCLSID , CLSCTX_ALL , NULL , IID_IClassFactory , (void **)&pClassFactory );
succeeds providing a pointer to IClassFactory However this line
res = pClassFactory->CreateInstance(0,IID_IAdd , (void **)&pAdd);
returns the following error
#define REGDB_E_IIDNOTREG _HRESULT_TYPEDEF_(0x80040155L)
Engineering is the effort !
-
I was able to modify my client code to do this
if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
{HRESULT res = CoGetClassObject(g\_MycfgCLSID , CLSCTX\_ALL , NULL , IID\_IClassFactory , (void \*\*)&pClassFactory ); if(SUCCEEDED(res)) { // res = pUnknown->QueryInterface(IID\_IAdd,(void \*\*)&pAdd); res = pClassFactory->CreateInstance(0,IID\_IAdd , (void \*\*)&pAdd); pClassFactory->Release(); } else if(res == E\_NOINTERFACE ) { int x = 1; } else if(res == E\_INVALIDARG) { int r = GetLastError() ; } CoUninitialize(); }
The call to
HRESULT res = CoGetClassObject(g_MycfgCLSID , CLSCTX_ALL , NULL , IID_IClassFactory , (void **)&pClassFactory );
succeeds providing a pointer to IClassFactory However this line
res = pClassFactory->CreateInstance(0,IID_IAdd , (void **)&pAdd);
returns the following error
#define REGDB_E_IIDNOTREG _HRESULT_TYPEDEF_(0x80040155L)
Engineering is the effort !
It states the class you're asking for is not registered. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke