Implementing IDebugProgramCreateEvent2
The second event typically sent to the session debug manager (SDM) is the program creation event, represented by the IDebugProgramCreateEvent2 interface. This event tells the SDM that the program is ready to be debugged.
TextInterpreter implements the IDebugProgramCreateEvent2 on the CProgramCreateEvent class, which is derived from both IDebugProgramCreateEvent2 and CEventBase.
To implement CProgramCreateEvent
In Solution Explorer, right-click the TextInterpreter project and click Add Class.
Add a Generic C++ Class with the Class name CProgramCreateEvent and set its Base class to IDebugProgramCreateEvent2. Set the .h file to EventBase.h and the .cpp file to EventBase.cpp. Make sure that Access is set to public. Click Finish. Answer Yes to the prompts that ask if you want to merge with the contents of the specified file.
Open the EventBase.h file, find the declaration for the new class CProgramCreateEvent, and modify the declaration to look like the following:
class CProgramCreateEvent : public IDebugProgramCreateEvent2, public CEventBase {
After the declaration of the CProgramCreateEvent destructor, add the following. This is the macro that declares the IUnknown interface methods.
~CProgramCreateEvent(void); //////////////////////////////////////////////////////////// // IUnknown methods DECLARE_IUNKNOWN
Open the EventBase.cpp file and modify the constructor for CProgramCreateEvent to look like this:
CProgramCreateEvent::CProgramCreateEvent(void) : CEventBase(IID_IDebugProgramCreateEvent2, EVENT_ASYNCHRONOUS) { }
At the end of EventBase.cpp, after the definition for the CProgramCreateEvent destructor, add the following. This is the macro that defines the IUnknown interface methods.
CProgramCreateEvent::~CProgramCreateEvent(void) { } ////////////////////////////////////////////////////////////////////////////// // IUnknown IMPLEMENT_IUNKNOWN(CProgramCreateEvent, IDebugProgramCreateEvent2)
Build the project to make sure there are no errors.