Debugger.CurrentProcess 属性

设置或获取活动进程。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
Property CurrentProcess As Process
Process CurrentProcess { get; set; }
property Process^ CurrentProcess {
    Process^ get ();
    void set (Process^ value);
}
abstract CurrentProcess : Process with get, set
function get CurrentProcess () : Process 
function set CurrentProcess (value : Process)

属性值

类型:EnvDTE.Process
一个 Process 对象。

备注

CurrentProcess 设置或返回活动的 Process。 活动进程即定义调试器所显示的数据的进程。 尽管调试器支持同时调试多个进程,但在任意给定时刻只能有一个进程处于活动状态。 有关更多信息,请参见<PAVEOVER> 调试多个进程

示例

下面的示例演示如何使用 CurrentProcess 属性。

测试此属性:

  1. 打开目标应用程序。 运行外接程序。 没有任何进程正在调试。

  2. 在目标应用程序中设置一个断点。 以调试模式运行此应用程序。

  3. 当程序停在该断点处时,运行外接程序。 正在调试该进程。

public static void CurrentProcess(DTE dte)
{
    // Setup the debug Output window.
    Window w = (Window)dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
    w.Visible = true;
    OutputWindow ow = (OutputWindow)w.Object;
    OutputWindowPane owp = ow.OutputWindowPanes.Add("Current Process Test");
    owp.Activate();

    owp.OutputString("Current Process Info: ");
    EnvDTE.Process process = dte.Debugger.CurrentProcess;
    if(process == null)
        owp.OutputString("No process is being debugged");
    else
        owp.OutputString("Process ID = " + process.ProcessID + 
                         "  Process Name = " + process.Name);
}
Shared Sub CurrentProcess(ByRef dte As EnvDTE.DTE)
     Dim process As EnvDTE.Process = dte.Debugger.CurrentProcess
     If process Is Nothing Then
         MessageBox.Show("No process is being debugged", "Debugger Test")
     Else
         MessageBox.Show("Process ID = " + process.ProcessID.ToString() + _
                         "  Process Name = " + process.Name, "Debugger Test")
     End If
 End Sub

.NET Framework 安全性

请参阅

参考

Debugger 接口

EnvDTE 命名空间