We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

Process2 Interface

The Process2 object is used to examine and manipulate processes. The Process2 object supersedes the Process object.

Namespace:  EnvDTE80
Assembly:  EnvDTE80 (in EnvDTE80.dll)

public interface Process2 : Process

The Process2 type exposes the following members.

Public propertyCollectionGets the collection containing the object supporting this property or contained within this code construct.
Public propertyDTEGets the top-level extensibility object.
Public propertyIsBeingDebuggedGets a value indicating if the program is being debugged.
Public propertyNameGets the name of the process.
Public propertyParentGets the immediate parent object of a Process2 object.
Public propertyProcessIDGets the ID number assigned to this process.
Public propertyProgramsGets a collection of Program objects.
Public propertyThreadsGets a collection of Thread objects.
Public propertyTransportGets the Transport being used to debug this process.
Public propertyTransportQualifierA computer name or an IP address.
Public propertyUserName

Public methodAttachCauses the debugger to attach this process.
Public methodAttach2Similar to Attach, causes the debugger to attach this process, only it allows you to specify an engine or set of engines.
Public methodBreakCauses the given process to pause its execution so that its current state can be analyzed.
Public methodDetachCauses the debugger to detach from this process.
Public methodTerminateTerminates this process.

' Macro code.
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Imports Microsoft.VisualBasic.ControlChars

Public Module Module1

    Sub NativeAttachToLocalCalc()
        Dim dbg2 As EnvDTE80.Debugger2
        dbg2 = DTE.Debugger

        Dim attached As Boolean = False
        Dim proc As EnvDTE80.Process2
        For Each proc In DTE.Debugger.LocalProcesses
            If (Right(proc.Name, 8) = "calc.exe") Then
                attached = True
                Exit For
            End If

        If attached = False Then
            If attached = False Then
                MsgBox("calc.exe isn't running")
            End If
        End If
    End Sub
End Module