Debugger3.LocalProcesses Property

Definition

Gets the list of processes that currently running on this computer.

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

    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  

Remarks

LocalProcesses gets a Processes collection that contains a list of processes that are running on this computer. 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