I try to refactor an existing and working COM event sink implementation. The event sink class is written in C++ and resides in a DLL that uses the deprecated CComModule class. The goal of the refactoring is to replace CComModule by the new ATL 7.0 class CAtlComModule.
The existing implementation declares a global variable somewhere in a .cpp file:
CComModule _Module;
As you can see the variable has the usual “magic” name _Module. The customary initialization is missing, though, nowhere is there a call to CComModule::Init() and there is also no COM object map in the DLL project. The event sink still works, its event handler methods get properly called.
Lacking any documentation how to transition from CComModule to CAtlComModule, I naively attempted to change the variable declaration to this:
CAtlComModule _Module;
It didn’t work out, though: After the change the event sink stopped working, i.e. its event handler methods no longer get called.
Does anyone know the steps one is supposed to perform to migrate to CAtlComModule? So far I have been unable to dig up a solution either on MSDN or via Google, but maybe I did not look properly…
BTW: If necessary I can provide more details about the event sink implementation, but so far I felt that the problem is not in this area.
The simplest “new style” replacement for
CComModulelooks like this: