June 9th, 2009, 08:57 PM
ATL project (simple COM server)
I created simple COM out-of-proc EXE server (CLSCTX_LOCAL_SERVER) using ATL project in Microsoft Visual Studio 2008. Also I added my class and my interface to the project. I don't need Automation, so I don't want to derive from IDispatch and my interface is not dual interface. Here is CMyClass definition in the header file:
MYSTRUCT structure (and PMYSTRUCT pointer) is defined in project's *.idl file and resides in MyServer_i.h header file generated by MIDL compiler. CreateMyObject method is defined in correspondent *.cpp file of CMyClass.
#include "resource.h" // main symbols
class ATL_NO_VTABLE CMyClass :
public CComCoClass<CMyClass , &CLSID_MyClass>,
// IMyClass interface
STDMETHOD(CreateMyObject)(ULONG ulType, PMYSTRUCT pMyStruct, ULONG* ulObjID);
Well, this project is compiled and linked perfectly without any problems.
My problem is that when I try to call CoCreateInstance of CMyClass COM object from different client appication and requesting IMyClass interface it fails to do so (returns NULL pointer). When I open OleView.exe application It shows My class in registered objects, but there is no IMyClass interface in the object. The interesting thing is that when I look to the type library (again using OleView) I can see IMyClass interface, CMyClass object and MYSTRUCT structure. I'm thinking might be COM_INTERFACE_ENTRY(IMyClass) macro somehow doesn't put IMyClass interface into CMyClass object interface MAP.
BTW if I use dual interface (IMyClass is derived from IDispatch using IDuspatchImpl) all is working (I can get IMyClass interface from client application). But I don't need to support IDispatch.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!