With CoRegisterClassObject and CoRegisterPSClsid registered after multiple IID interface within the main thread, in the current thread with QueryService can get to the interface, but the other thread created will not be able to get to the interface, return "no registered class" error,
Registration code is as follows:
DLLINFO Dll_GetProxyDllInfo=(DLLINFO) GetProcAddress call (dllHandle, "GetProxyDllInfo");
If (Dll_GetProxyDllInfo==NULL) {
FreeLibrary (dllHandle);
return;
}
//agent information was obtained from the DLL (interface IIDs and the proxy stubs clsids)
Clsids * pProxyClsid=NULL;
* * pProxyInfo ProxyFileInfo=NULL;
Dll_GetProxyDllInfo (& amp; PProxyInfo, & amp; PProxyClsid);
if(! PProxyClsid | |! PProxyInfo) {
FreeLibrary (dllHandle);
return;
IUnknown * ClassObjPunk=NULL;
Res=CoGetClassObject (* pProxyClsid CLSCTX_INPROC_SERVER, nullptr IID_IUnknown, (void * *) & amp; ClassObjPunk);
DeactivateActCtx (0, actCtxCookie);
ReleaseActCtx (hActCtx);
If (res! S_OK)={
FreeLibrary (dllHandle);
return;
}
//to COM register class object,
DWORD dwCookie;
Res=CoRegisterClassObject (regClsid ClassObjPunk, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, & amp; DwCookie);
ClassObjPunk - & gt; LpVtbl - & gt; Release (ClassObjPunk);
If (res! S_OK)={
FreeLibrary (dllHandle);
return;
CodePudding user response:
Try thread CoInitialize or CoInitializeEx first initialize the COM librariesCodePudding user response: