Compartir a través de


Inserting the Program Object

This part of the tutorial uses the Visual Studio ATL Object wizard to add a class that supports the IDebugProgram2 and IDebugProgram2 interfaces.

To insert the program object

  1. In Solution Explorer, right-click the TextInterpreter module and click Add Class.

  2. Click the ATL category, click an ATL Simple Object, and click Add.

  3. Type Program for the short name; the other fields will automatically be filled in.

  4. Clear the Attributed option.

  5. Change the Interface to IDebugProgramNode2.

  6. Click Next or click the Options link on the left.

  7. Change the Interface from Dual to Custom.

  8. Click Finish to add the ATL object to the project.

  9. Open the TextInterpreter.idl file.

  10. Remove the IDebugProgramNode2 interface declaration; it will look similar to the following lines (the uuid may be different):

    [
        object,
        uuid(6E5E5228-435D-4353-8413-BB54FEC7BF6C),
        helpstring("IDebugProgramNode2 Interface"),
        pointer_default(unique)
    ]
    interface IDebugProgramNode2 : IUnknown{
    };
    
  11. Open the Program.h file and add the following bold lines. These are the declarations for the methods on the IDebugProgramNode2 interface.

    END_COM_MAP()
    
        //////////////////////////////////////////////////////////// 
        // IDebugProgramNode2 
        STDMETHOD(CreatePendingBreakpoint)( 
            IDebugBreakpointRequest2 *pBPRequest, 
            IDebugPendingBreakpoint2** ppPendingBP); 
        STDMETHOD(GetProgramName)(BSTR* pbstrProgramName); 
        STDMETHOD(GetHostName)(DWORD dwHostNameType, BSTR* pbstrHostName); 
        STDMETHOD(GetHostPid)(AD_PROCESS_ID *pHostProcessId); 
        STDMETHOD(GetHostMachineName_V7)(BSTR* pbstrHostMachineName); 
        STDMETHOD(Attach_V7)( 
            IDebugProgram2* pMDMProgram, 
            IDebugEventCallback2* pCallback, 
            DWORD dwReason); 
        STDMETHOD(GetEngineInfo)(BSTR* pbstrEngine, GUID* pguidEngine); 
        STDMETHOD(DetachDebugger_V7)(void); 
    
  12. Open the Program.cpp file and add the following bold lines. These are the definitions for the IDebugProgramNode2 interface methods. These will all return E_NOTIMPL for the moment.

    // CProgram
    
    ////////////////////////////////////////////////////////////////////////////// 
    // IDebugProgramNode2 methods 
    HRESULT CProgram::GetProgramName(BSTR* pbstrProgramName) 
    { return E_NOTIMPL; } 
    HRESULT CProgram::GetHostName(DWORD dwHostNameType, BSTR* pbstrHostName) 
    { return E_NOTIMPL; } 
    HRESULT CProgram::GetHostMachineName_V7(BSTR* pbstrHostMachineName) 
    { return E_NOTIMPL; } 
    HRESULT CProgram::DetachDebugger_V7(void) 
    { return E_NOTIMPL; } 
    HRESULT CProgram::Attach_V7(IDebugProgram2* pMDMProgram,                            IDebugEventCallback2* pCallback, 
                                DWORD dwReason) 
    { return E_NOTIMPL; } 
    
    HRESULT CProgram::GetEngineInfo(BSTR* pbstrEngine, GUID* pguidEngine) 
    { 
        //TODO: RETURN ENGINE INFO 
        return E_NOTIMPL; 
    } 
    
    HRESULT CProgram::GetHostPid(AD_PROCESS_ID *pHostProcessId) 
    { 
        //TODO: RETURN HOST PID 
        return E_NOTIMPL; 
    } 
    
    HRESULT CProgram::CreatePendingBreakpoint(IDebugBreakpointRequest2 *pBPRequest, 
                                              IDebugPendingBreakpoint2 **ppPendingBP) 
    { 
        //TODO: CREATE BREAKPOINT 
        return E_NOTIMPL; 
    } 
    
  13. Build the project to make sure there are no errors.

See Also

Concepts

Adding the Program Object