Process.GetProcesses Process.GetProcesses Process.GetProcesses Process.GetProcesses Method

Definition

Erstellt ein Array neuer Process-Komponenten und ordnet diese den vorhandenen Prozessressourcen zu.Creates an array of new Process components and associates them with existing process resources.

Überlädt

GetProcesses(String) GetProcesses(String) GetProcesses(String) GetProcesses(String)

Erstellt eine neue Process-Komponente für jede Prozessressource auf dem lokalen Computer.Creates a new Process component for each process resource on the specified computer.

GetProcesses() GetProcesses() GetProcesses() GetProcesses()

Erstellt eine neue Process-Komponente für jede Prozessressource auf dem lokalen Computer.Creates a new Process component for each process resource on the local computer.

GetProcesses(String) GetProcesses(String) GetProcesses(String) GetProcesses(String)

Erstellt eine neue Process-Komponente für jede Prozessressource auf dem lokalen Computer.Creates a new Process component for each process resource on the specified computer.

public:
 static cli::array <System::Diagnostics::Process ^> ^ GetProcesses(System::String ^ machineName);
public static System.Diagnostics.Process[] GetProcesses (string machineName);
static member GetProcesses : string -> System.Diagnostics.Process[]
Public Shared Function GetProcesses (machineName As String) As Process()

Parameter

machineName
String String String String

Der Computer, von dem die Liste der Prozesse gelesen werden soll.The computer from which to read the list of processes.

Gibt zurück

Ein Array vom Typ Process, das alle auf dem angegebenen Computer ausgeführten Prozessressourcen darstellt.An array of type Process that represents all the process resources running on the specified computer.

Ausnahmen

Die Syntax des machineName-Parameters ist ungültig.The machineName parameter syntax is invalid. Sie kann die Länge 0 (null) haben.It might have length zero (0).

Der machineName-Parameter ist null.The machineName parameter is null.

Die Betriebssystemplattform unterstützt diesen Vorgang nicht auf Remotecomputern.The operating system platform does not support this operation on remote computers.

Es gibt Probleme beim Zugriff auf die Leistungsindikator-APIs zum Abrufen von Prozessinformationen.There are problems accessing the performance counter API's used to get process information. Diese Ausnahme tritt nur unter Windows NT, Windows 2000 und Windows XP auf.This exception is specific to Windows NT, Windows 2000, and Windows XP.

Beim Zugriff auf eine zugrunde liegende System-API ist ein Problem aufgetreten.A problem occurred accessing an underlying system API.

Beispiele

Im folgende Beispiel ruft die Informationen des aktuellen Prozesses aus, auf dem lokalen Computer, alle ausgeführten Instanzen von Editor auf dem lokalen Computer und einen bestimmten Prozess auf dem lokalen Computer ausgeführten Prozesse ab.The following example retrieves information of the current process, processes running on the local computer, all instances of Notepad running on the local computer, and a specific process on the local computer. Klicken Sie dann die Informationen für die gleichen Prozesse auf einem Remotecomputer abgerufen.It then retrieves information for the same processes on a remote computer.

#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::ComponentModel;
int main()
{   
   // Get the current process.    
   Process^ currentProcess = Process::GetCurrentProcess();

   // Get all processes running on the local computer.
   array<Process^>^localAll = Process::GetProcesses();

   // Get all instances of Notepad running on the local computer.
   // This will return an empty array if notepad isn't running.
   array<Process^>^localByName = Process::GetProcessesByName("notepad");

   // Get a process on the local computer, using the process id.
   // This will throw an exception if there is no such process.
   Process^ localById = Process::GetProcessById(1234);


   // Get processes running on a remote computer. Note that this
   // and all the following calls will timeout and throw an exception
   // if "myComputer" and 169.0.0.0 do not exist on your local network.

   // Get all processes on a remote computer.
   array<Process^>^remoteAll = Process::GetProcesses("myComputer");

   // Get all instances of Notepad running on the specific computer, using machine name.
   array<Process^>^remoteByName = Process::GetProcessesByName( "notepad", "myComputer" );
   
   // Get all instances of Notepad running on the specific computer, using IP address.
   array<Process^>^ipByName = Process::GetProcessesByName( "notepad", "169.0.0.0" );
   
   // Get a process on a remote computer, using the process id and machine name.
   Process^ remoteById = Process::GetProcessById( 2345, "myComputer" );
}
using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
{
    class MyProcess
    {
        void BindToRunningProcesses()
        {
            // Get the current process.
            Process currentProcess = Process.GetCurrentProcess();

            // Get all processes running on the local computer.
            Process[] localAll = Process.GetProcesses();

            // Get all instances of Notepad running on the local computer.
            // This will return an empty array if notepad isn't running.
            Process[] localByName = Process.GetProcessesByName("notepad");

            // Get a process on the local computer, using the process id.
            // This will throw an exception if there is no such process.
            Process localById = Process.GetProcessById(1234);


            // Get processes running on a remote computer. Note that this
            // and all the following calls will timeout and throw an exception
            // if "myComputer" and 169.0.0.0 do not exist on your local network.

            // Get all processes on a remote computer.
            Process[] remoteAll = Process.GetProcesses("myComputer");

            // Get all instances of Notepad running on the specific computer, using machine name.
            Process[] remoteByName = Process.GetProcessesByName("notepad", "myComputer");

            // Get all instances of Notepad running on the specific computer, using IP address.
            Process[] ipByName = Process.GetProcessesByName("notepad", "169.0.0.0");

            // Get a process on a remote computer, using the process id and machine name.
            Process remoteById = Process.GetProcessById(2345, "myComputer");
        }

        static void Main()
        {
            MyProcess myProcess = new MyProcess();
            myProcess.BindToRunningProcesses();
        }
    }
}
Imports System
Imports System.Diagnostics
Imports System.ComponentModel

Namespace MyProcessSample
    Class MyProcess
        Sub BindToRunningProcesses()
            ' Get the current process. You can use currentProcess from this point
            ' to access various properties and call methods to control the process.
            Dim currentProcess As Process = Process.GetCurrentProcess()

            ' Get all processes running on the local computer.
            Dim localAll As Process() = Process.GetProcesses()

            ' Get all instances of Notepad running on the local computer.
            ' This will return an empty array if notepad isn't running.
            Dim localByName As Process() = Process.GetProcessesByName("notepad")

            ' Get a process on the local computer, using the process id.
            ' This will throw an exception if there is no such process.
            Dim localById As Process = Process.GetProcessById(1234)


            ' Get processes running on a remote computer. Note that this
            ' and all the following calls will timeout and throw an exception
            ' if "myComputer" and 169.0.0.0 do not exist on your local network.

            ' Get all processes on a remote computer.
            Dim remoteAll As Process() = Process.GetProcesses("myComputer")

            ' Get all instances of Notepad running on the specific computer, using machine name.
            Dim remoteByName As Process() = Process.GetProcessesByName("notepad", "myComputer")

            ' Get all instances of Notepad running on the specific computer, using IP address.
            Dim ipByName As Process() = Process.GetProcessesByName("notepad", "169.0.0.0")

            ' Get a process on a remote computer, using the process id and machine name.
            Dim remoteById As Process = Process.GetProcessById(2345, "myComputer")
        End Sub 'BindToRunningProcesses

        Shared Sub Main()
            Dim myProcess As New MyProcess()
            myProcess.BindToRunningProcesses()
        End Sub 'Main 

    End Class 'MyProcess

End Namespace 'MyProcessSample

Hinweise

Verwenden Sie diese Methode zum Erstellen von neuen ein Array von Process Komponenten und diese allen Prozessressourcen auf dem angegebenen (in der Regel remoten) Computer zuordnen.Use this method to create an array of new Process components and associate them with all the process resources on the specified (usually remote) computer. Prozessressourcen müssen bereits auf dem lokalen Computer vorhanden, da GetProcesses erstellt keine Systemressourcen, sondern Ressourcen durch die Anwendung generierte zuordnet Process Komponenten.The process resources must already exist on the local computer, because GetProcesses does not create system resources but rather associates resources with application-generated Process components. Da das Betriebssystem selbst Hintergrundprozesse ausgeführt wird, ist dieses Array niemals leer.Because the operating system itself is running background processes, this array is never empty.

Wenn Sie nicht, um alle auf dem Computer ausgeführten Prozesse abzurufen möchten, können Sie deren Anzahl einschränken, indem Sie mit der GetProcessById oder GetProcessesByName Methode.If you do not want to retrieve all the processes running on the computer, you can restrict their number by using the GetProcessById or GetProcessesByName method. GetProcessById erstellt eine Process Komponente, mit dem Prozess, der auf dem System durch die Prozess-ID, die Sie an die Methode übergeben identifiziert zugeordnet ist.GetProcessById creates a Process component that is associated with the process identified on the system by the process identifier that you pass to the method. GetProcessesByName erstellt ein Array von Process -Komponenten, deren zugeordneten Prozessressourcen gemeinsam, die ausführbare Datei nutzen, die Sie an die Methode übergeben.GetProcessesByName creates an array of Process components whose associated process resources share the executable file you pass to the method.

Diese Überladung von der GetProcesses -Methode in der Regel verwendet, um die Liste der auf einem Remotecomputer im Netzwerk ausgeführten Prozessressourcen abrufen, aber Sie können den lokalen Computer angeben, durch das übergeben ".".This overload of the GetProcesses method is generally used to retrieve the list of process resources running on a remote computer on the network, but you can specify the local computer by passing ".".

Hinweis

Mehrere Windows-Dienste können innerhalb der gleichen Instanz von der Service Host-Prozess (svchost.exe) geladen werden.Multiple Windows services can be loaded within the same instance of the Service Host process (svchost.exe). GetProcesses identifiziert die einzelnen Dienste nicht; finden Sie unter GetServices.GetProcesses does not identify those individual services; for that, see GetServices.

Sicherheit

LinkDemand
für volle Vertrauenswürdigkeit für den unmittelbaren Aufrufer.for full trust for the immediate caller. Dieser Member kann von nur teilweise vertrauenswürdigem Code nicht verwendet werden.This member cannot be used by partially trusted code.

Siehe auch

GetProcesses() GetProcesses() GetProcesses() GetProcesses()

Erstellt eine neue Process-Komponente für jede Prozessressource auf dem lokalen Computer.Creates a new Process component for each process resource on the local computer.

public:
 static cli::array <System::Diagnostics::Process ^> ^ GetProcesses();
public static System.Diagnostics.Process[] GetProcesses ();
static member GetProcesses : unit -> System.Diagnostics.Process[]
Public Shared Function GetProcesses () As Process()

Gibt zurück

Ein Array vom Typ Process, das alle auf dem lokalen Computer ausgeführten Prozessressourcen darstellt.An array of type Process that represents all the process resources running on the local computer.

Beispiele

Im folgende Beispiel ruft die Informationen des aktuellen Prozesses aus, auf dem lokalen Computer, alle ausgeführten Instanzen von Editor auf dem lokalen Computer und einen bestimmten Prozess auf dem lokalen Computer ausgeführten Prozesse ab.The following example retrieves information of the current process, processes running on the local computer, all instances of Notepad running on the local computer, and a specific process on the local computer. Klicken Sie dann die Informationen für die gleichen Prozesse auf einem Remotecomputer abgerufen.It then retrieves information for the same processes on a remote computer.

#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::ComponentModel;
int main()
{   
   // Get the current process.    
   Process^ currentProcess = Process::GetCurrentProcess();

   // Get all processes running on the local computer.
   array<Process^>^localAll = Process::GetProcesses();

   // Get all instances of Notepad running on the local computer.
   // This will return an empty array if notepad isn't running.
   array<Process^>^localByName = Process::GetProcessesByName("notepad");

   // Get a process on the local computer, using the process id.
   // This will throw an exception if there is no such process.
   Process^ localById = Process::GetProcessById(1234);


   // Get processes running on a remote computer. Note that this
   // and all the following calls will timeout and throw an exception
   // if "myComputer" and 169.0.0.0 do not exist on your local network.

   // Get all processes on a remote computer.
   array<Process^>^remoteAll = Process::GetProcesses("myComputer");

   // Get all instances of Notepad running on the specific computer, using machine name.
   array<Process^>^remoteByName = Process::GetProcessesByName( "notepad", "myComputer" );
   
   // Get all instances of Notepad running on the specific computer, using IP address.
   array<Process^>^ipByName = Process::GetProcessesByName( "notepad", "169.0.0.0" );
   
   // Get a process on a remote computer, using the process id and machine name.
   Process^ remoteById = Process::GetProcessById( 2345, "myComputer" );
}
using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
{
    class MyProcess
    {
        void BindToRunningProcesses()
        {
            // Get the current process.
            Process currentProcess = Process.GetCurrentProcess();

            // Get all processes running on the local computer.
            Process[] localAll = Process.GetProcesses();

            // Get all instances of Notepad running on the local computer.
            // This will return an empty array if notepad isn't running.
            Process[] localByName = Process.GetProcessesByName("notepad");

            // Get a process on the local computer, using the process id.
            // This will throw an exception if there is no such process.
            Process localById = Process.GetProcessById(1234);


            // Get processes running on a remote computer. Note that this
            // and all the following calls will timeout and throw an exception
            // if "myComputer" and 169.0.0.0 do not exist on your local network.

            // Get all processes on a remote computer.
            Process[] remoteAll = Process.GetProcesses("myComputer");

            // Get all instances of Notepad running on the specific computer, using machine name.
            Process[] remoteByName = Process.GetProcessesByName("notepad", "myComputer");

            // Get all instances of Notepad running on the specific computer, using IP address.
            Process[] ipByName = Process.GetProcessesByName("notepad", "169.0.0.0");

            // Get a process on a remote computer, using the process id and machine name.
            Process remoteById = Process.GetProcessById(2345, "myComputer");
        }

        static void Main()
        {
            MyProcess myProcess = new MyProcess();
            myProcess.BindToRunningProcesses();
        }
    }
}
Imports System
Imports System.Diagnostics
Imports System.ComponentModel

Namespace MyProcessSample
    Class MyProcess
        Sub BindToRunningProcesses()
            ' Get the current process. You can use currentProcess from this point
            ' to access various properties and call methods to control the process.
            Dim currentProcess As Process = Process.GetCurrentProcess()

            ' Get all processes running on the local computer.
            Dim localAll As Process() = Process.GetProcesses()

            ' Get all instances of Notepad running on the local computer.
            ' This will return an empty array if notepad isn't running.
            Dim localByName As Process() = Process.GetProcessesByName("notepad")

            ' Get a process on the local computer, using the process id.
            ' This will throw an exception if there is no such process.
            Dim localById As Process = Process.GetProcessById(1234)


            ' Get processes running on a remote computer. Note that this
            ' and all the following calls will timeout and throw an exception
            ' if "myComputer" and 169.0.0.0 do not exist on your local network.

            ' Get all processes on a remote computer.
            Dim remoteAll As Process() = Process.GetProcesses("myComputer")

            ' Get all instances of Notepad running on the specific computer, using machine name.
            Dim remoteByName As Process() = Process.GetProcessesByName("notepad", "myComputer")

            ' Get all instances of Notepad running on the specific computer, using IP address.
            Dim ipByName As Process() = Process.GetProcessesByName("notepad", "169.0.0.0")

            ' Get a process on a remote computer, using the process id and machine name.
            Dim remoteById As Process = Process.GetProcessById(2345, "myComputer")
        End Sub 'BindToRunningProcesses

        Shared Sub Main()
            Dim myProcess As New MyProcess()
            myProcess.BindToRunningProcesses()
        End Sub 'Main 

    End Class 'MyProcess

End Namespace 'MyProcessSample

Hinweise

Verwenden Sie diese Methode zum Erstellen von neuen ein Array von Process Komponenten und allen Prozessressourcen auf dem lokalen Computer zugeordnet werden.Use this method to create an array of new Process components and associate them with all the process resources on the local computer. Prozessressourcen müssen bereits auf dem lokalen Computer vorhanden, da GetProcesses erstellt keine Systemressourcen, sondern Ressourcen durch die Anwendung generierte zuordnet Process Komponenten.The process resources must already exist on the local computer, because GetProcesses does not create system resources but rather associates resources with application-generated Process components. Da das Betriebssystem selbst Hintergrundprozesse ausgeführt wird, ist dieses Array niemals leer.Because the operating system itself is running background processes, this array is never empty.

Wenn Sie nicht, um alle auf dem Computer ausgeführten Prozesse abzurufen möchten, können Sie deren Anzahl einschränken, indem Sie mit der GetProcessById oder GetProcessesByName Methode.If you do not want to retrieve all the processes running on the computer, you can restrict their number by using the GetProcessById or GetProcessesByName method. GetProcessById erstellt eine Process Komponente, mit dem Prozess, der auf dem System durch die Prozess-ID, die Sie an die Methode übergeben identifiziert zugeordnet ist.GetProcessById creates a Process component that is associated with the process identified on the system by the process identifier that you pass to the method. GetProcessesByName erstellt ein Array von Process -Komponenten, deren zugeordneten Prozessressourcen gemeinsam, die ausführbare Datei nutzen, die Sie an die Methode übergeben.GetProcessesByName creates an array of Process components whose associated process resources share the executable file you pass to the method.

Hinweis

Mehrere Windows-Dienste können innerhalb der gleichen Instanz von der Service Host-Prozess (svchost.exe) geladen werden.Multiple Windows services can be loaded within the same instance of the Service Host process (svchost.exe). GetProcesses identifiziert die einzelnen Dienste nicht; finden Sie unter GetServices.GetProcesses does not identify those individual services; for that, see GetServices.

Sicherheit

LinkDemand
für volle Vertrauenswürdigkeit für den unmittelbaren Aufrufer.for full trust for the immediate caller. Dieser Member kann von nur teilweise vertrauenswürdigem Code nicht verwendet werden.This member cannot be used by partially trusted code.

Siehe auch

Gilt für: