Partager via


Debugger2.LocalProcesses Property

Definition

Gets the list of processes currently running on this machine.

public:
 property EnvDTE::Processes ^ LocalProcesses { EnvDTE::Processes ^ get(); };
[System.Runtime.InteropServices.DispId(113)]
public EnvDTE.Processes LocalProcesses { [System.Runtime.InteropServices.DispId(113)] get; }
[<System.Runtime.InteropServices.DispId(113)>]
[<get: System.Runtime.InteropServices.DispId(113)>]
member this.LocalProcesses : EnvDTE.Processes
Public ReadOnly Property LocalProcesses As Processes

Property Value

A Processes collection.

Implements

Attributes

Examples

The following example demonstrates how to use the LocalProcesses property.

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();  

    EnvDTE80.Debugger2 debugger = (EnvDTE80.Debugger2)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 (EnvDTE80.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  

Remarks

LocalProcesses gets a Processes collection containing a list of processes running on this machine. Each process in the list might or might not be currently debugged. To get the subset of processes that are currently being debugged, use the DebuggedProcesses.

Applies to