How to use the CoGetClassObject function in x64
I have a COM library that is compiled in 32 bit (server side). I registered it and tried to call CoGetClassObject()
from a 32 bit client to get it IClassFactory
.
Hr = CoGetClassObject(CLSID_IOrbCom, CLSCTX_INPROC_SERVER, 0 , IDD_IClassFactory, (LPVOID*)&ClassFactory)
and it works great for a 32 bit client. But when I tried to call CoGetClassObject()
from a 64 bit client, I got a "Class not registered" error.
I can only have a COM server compiled in 32 bit mode. My OS is Windows XP 64-bit.
How do I get it to work?
a source to share
This is the expected behavior - you cannot load a 32 bit dll into a 64 bit client process, it is simply not supported by the OS. You will either have to recompile the server (and register it as 64-bit) or use DCOM, COM +, or another interoperability solution that will run 32-bit code in a separate process and invoke calls from the client to that process using RPC.
a source to share