Q: how to expose an interface using ATL?
-
Hi, In MFC, people can derive a class (say CA) from CCmdTarget, and then use macros such as BEGIN_DUAL_INTERFACE_PART, BEGIN_INTERFACE_MAP etc. to expose an interface. Another dll can access this interface by instantiating CA and then call CA's GetInterface(). My question is how to achieve the same thing using ATL? I tried to create a ATL project with a COM class exposing a dual interface. If I instantiate the COM class, I would get a compile error saying virtual functions AddRef, Release,QueryInterface are not implemented. I don't need proxy/stub code involved becuase this interface is accessed not through COM actually. The reason I have to do this because another DLL requires my DLL's exported class to expose a dual interface for it. Thanks in advance for your big help and precious time. Tony
-
Hi, In MFC, people can derive a class (say CA) from CCmdTarget, and then use macros such as BEGIN_DUAL_INTERFACE_PART, BEGIN_INTERFACE_MAP etc. to expose an interface. Another dll can access this interface by instantiating CA and then call CA's GetInterface(). My question is how to achieve the same thing using ATL? I tried to create a ATL project with a COM class exposing a dual interface. If I instantiate the COM class, I would get a compile error saying virtual functions AddRef, Release,QueryInterface are not implemented. I don't need proxy/stub code involved becuase this interface is accessed not through COM actually. The reason I have to do this because another DLL requires my DLL's exported class to expose a dual interface for it. Thanks in advance for your big help and precious time. Tony
In ATL, your CA class is an abstract base class - it doesn't have implementations of the IUnknown methods, as you've found out from the compiler errors. See KB article Q181265 for the steps you take to make a new object. Basically, you instantiate a CComObject<CA> instead - CComObject provides the IUnknown implementation. --Mike-- http://home.inreach.com/mdunn/ "That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas." --Buffy