Compartir a través de


IDebugProgramPublisher2

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

This interface allows a debug engine (DE) or custom port suppliers to register programs for debugging.

Syntax

IDebugProgramPublisher2 : IUnknown

Notes for Implementers

Visual Studio implements this interface to register programs being debugged in order to make them visible for debugging across multiple processes.

Notes for Callers

Call COM's CoCreateInstance function with CLSID_ProgramPublisher to obtain this interface (see the Example). A DE or a custom port supplier uses this interface to register program nodes that represent programs being debugged.

Methods in Vtable order

This interface implements the following methods:

Method Description
PublishProgramNode Makes a program node available to DEs and the session debug manager (SDM).
UnpublishProgramNode Removes a program node so that it is no longer available.
PublishProgram Makes a program available to DEs and the SDM.
UnpublishProgram Removes a program so it is no longer available.
SetDebuggerPresent Sets a flag indicating that a debugger is present.

Remarks

This interface makes programs and program nodes available (that is, "publishes" them) for use by DEs and the session debug manager (SDM). To access published programs and program nodes, use the IDebugProgramProvider2 interface. This is the only way Visual Studio can recognize that a program is being debugged.

Requirements

Header: msdbg.h

Namespace: Microsoft.VisualStudio.Debugger.Interop

Assembly: Microsoft.VisualStudio.Debugger.Interop.dll

Example

This example shows how to instantiate the program publisher and register a program node. This is taken from the Tutorial, Publishing the Program Node.

// This is how m_srpProgramPublisher is defined in the class definition:
// CComPtr<IDebugProgramPublisher2> m_srpProgramPublisher.

void CProgram::Start(IDebugEngine2 * pEngine)
{
    m_spEngine = pEngine;

    HRESULT hr = m_srpProgramPublisher.CoCreateInstance(CLSID_ProgramPublisher);
    if ( FAILED(hr) )
    {
        ATLTRACE("Failed to create the program publisher: 0x%x.", hr);
        return;
    }

    // Register ourselves with the program publisher. Note that
    // CProgram implements the IDebgProgramNode2 interface, hence
    // the static cast on "this".
    hr = m_srpProgramPublisher->PublishProgramNode(
        static_cast<IDebugProgramNode2*>(this));
    if ( FAILED(hr) )
    {
        ATLTRACE("Failed to publish the program node: 0x%x.", hr);
        m_srpProgramPublisher.Release();
        return;
    }

    ATLTRACE("Added program node.\n");
}

See also