Hello,
I'm trying to use an existing IDL file and create a COM server using the provided interfaces. I have been able to create a project, compile the IDL using Visual Studio's built-in MIDL compiler, and create a class inheriting the interface, with functionality.
This project successfully compiles as a DLL.
When I attempt to use my COM server in another application (I #define DLLPATH to the path of my DLL):
#import DLLPATH named_guids
HRESULT hr = CoCreateInstance(....); // instance created using the CLSCTX_INPROC_SERVER flag
My application compiles, but my interface pointer is NULL and I receive the following HRESULT:
REGDB_E_CLASSNOTREG
Classfactory cannot supply requested class.
I'm assuming this is a result of my COM DLL being improperly registered via regsvr32; however, I have attempted registering my DLL with regsvr32 on every build, and each register is successful. I have been reading as much support as I can (with very
little documentation on MIDL and COM I might add) and the MIDL compiler flag REGISTER_PROXY_DLL
should define DllEntryPoint, DllRegisterServer, and DllUnregisterServer for me, but it does not. MIDL ONLY generates DllGetClassObject and DllCanUnloadNow. I have not been able to figure out how to tell MIDL via Visual Studio
to either auto-generate DllEntryPoint, DllRegisterServer, and DllUnregisterServer, or to tell MIDL NOT to auto-generate DllGetClassObject and DllCanUnloadNow.
I have attempted manually entering registry keys into the HKEY_CLASSES_ROOT\CLSID, HKEY_CLASSES_ROOT\Interfaces, and HKEY_CLASSES_ROOT\AppID keys, but nothing has worked and I can find no documentation on the precise setup of COM registry keys.