I am trying to do some COM/OLE, here is my code :
static struct IUnknown* punk = NULL;
static IDispatch* UIRManager = NULL;
void DispatcherStart(){
CoInitialize(NULL);
HRESULT retour = GetActiveObject(&CLSID_OASIQ_,NULL,&punk);
if(retour != S_OK){
return;
}
HRESULT hr = IUnknown_QueryInterface_Proxy(punk,&IID_UIRManager_,(void**) &UIRManager); // General protection fault
...
For some reason, IUnknown_QueryInterface_Proxy cause a General protection fault. I dont see what I'm doing wrong ?
This function is called from a different thread than the main thread but since I call CoInitialize it's not the cause of error. I'm on C99 compiling a 32bit executable on W10
The C implementation of IUnknow is different than C++. The comon way to call QueryInterface is not by using IUnknown_QueryInterface_Proxy (from RpcRT4.lib) but to do this :
HRESULT hr = (punk)->lpVtbl -> QueryInterface(punk,&IID_UIRManager_,(void**) &UIRManager);