Debugger3.LocalProcesses 属性

获取此计算机上当前正在运行的进程的列表。

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

语法

声明
ReadOnly Property LocalProcesses As Processes
Processes LocalProcesses { get; }
property Processes^ LocalProcesses {
    Processes^ get ();
}
abstract LocalProcesses : Processes with get
function get LocalProcesses () : Processes

属性值

类型:Processes
一个 Processes 集合。

备注

LocalProcesses 获取一个 Processes 集合,该集合包含此计算机上正在运行的进程的列表。 该列表中的每个进程当前可能正在调试,也可能未在调试。 若要获取当前正在调试的进程的子集,请使用 DebuggedProcesses

示例

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

测试此属性:

  1. 打开目标项目并运行外接程序。
public static void LocalProcesses(EnvDTE80.DTE2 dte)
{
    // Setup 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("Local Processes 
    Test");
    owp.Activate();

    EnvDTE90.Debugger3 debugger = (EnvDTE90.Debugger3)dte.Debugger;
    EnvDTE.Processes processes = debugger.LocalProcesses;
    if (processes.Count == 0)
        owp.OutputString("No processes are running on this machine.");
    else
    {
        owp.OutputString("Processes running on this machine:");
        foreach (EnvDTE90.Process2 proc in processes)
            owp.OutputString("\nProcess: [" + proc.ProcessID + "] " + 
                             proc.Name);
    }
}
Sub AttachToCalc()

    ' This function attaches to calc.exe if it is running.

    Dim attached As Boolean = False

    Dim proc As EnvDTE.Process
    For Each proc In DTE2.Debugger.LocalProcesses
        If (Right(proc.Name, 8) = "calc.exe") Then
            proc.Attach()
            attached = True
            Exit For
        End If
    Next

    If attached = False Then
        MsgBox("calc.exe is not running")
    End If
End Sub

.NET Framework 安全性

请参阅

参考

Debugger3 接口

EnvDTE90 命名空间