Process.GetProcesses 메서드

정의

Process 구성 요소로 이루어진 배열을 만들어 기존 프로세스 리소스에 연결합니다.

오버로드

GetProcesses()

로컬 컴퓨터의 각 프로세스 리소스에 대해 새 Process 구성 요소를 만듭니다.

GetProcesses(String)

지정한 컴퓨터의 각 프로세스 리소스에 대해 새 Process 구성 요소를 만듭니다.

GetProcesses()

Source:
Process.cs
Source:
Process.cs
Source:
Process.cs

로컬 컴퓨터의 각 프로세스 리소스에 대해 새 Process 구성 요소를 만듭니다.

public:
 static cli::array <System::Diagnostics::Process ^> ^ GetProcesses();
public static System.Diagnostics.Process[] GetProcesses ();
[System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static System.Diagnostics.Process[] GetProcesses ();
static member GetProcesses : unit -> System.Diagnostics.Process[]
[<System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member GetProcesses : unit -> System.Diagnostics.Process[]
Public Shared Function GetProcesses () As Process()

반환

로컬 컴퓨터에서 실행 중인 모든 프로세스 리소스를 나타내는 Process 형식의 배열입니다.

특성

예제

다음 예제에서는 현재 프로세스의 정보, 로컬 컴퓨터에서 실행되는 프로세스, 로컬 컴퓨터에서 실행되는 메모장의 모든 인스턴스 및 로컬 컴퓨터의 특정 프로세스를 검색합니다. 그런 다음 원격 컴퓨터에서 동일한 프로세스에 대한 정보를 검색합니다.

#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.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

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

    End Class

End Namespace 'MyProcessSample

설명

이 메서드를 사용하여 새 Process 구성 요소의 배열을 만들고 로컬 컴퓨터의 모든 프로세스 리소스와 연결합니다. 때문에 로컬 컴퓨터의 프로세스 리소스에 이미 존재 해야 합니다 GetProcesses 시스템 리소스를 만들지는 않지만 대신 애플리케이션에서 생성 된 리소스를 연결 Process 구성 요소입니다. 운영 체제 자체가 백그라운드 프로세스를 실행하고 있으므로 이 배열은 비어 있지 않습니다.

컴퓨터에서 실행되는 모든 프로세스를 검색하지 않으려면 또는 GetProcessesByName 메서드를 사용하여 GetProcessById 해당 프로세스를 제한할 수 있습니다. GetProcessById 는 메서드에 Process 전달하는 프로세스 식별자에 의해 시스템에서 식별된 프로세스와 연결된 구성 요소를 만듭니다. GetProcessesByName 는 연결된 프로세스 리소스가 메서드에 전달하는 실행 파일을 공유하는 구성 요소의 배열 Process 을 만듭니다.

참고

여러 Windows 서비스는 svchost.exe(서비스 호스트 프로세스)의 동일한 instance 내에 로드할 수 있습니다. GetProcesses는 이러한 개별 서비스를 식별하지 않습니다. 이 경우 을 참조하세요 GetServices.

추가 정보

적용 대상

GetProcesses(String)

Source:
Process.cs
Source:
Process.cs
Source:
Process.cs

지정한 컴퓨터의 각 프로세스 리소스에 대해 새 Process 구성 요소를 만듭니다.

public:
 static cli::array <System::Diagnostics::Process ^> ^ GetProcesses(System::String ^ machineName);
public static System.Diagnostics.Process[] GetProcesses (string machineName);
[System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static System.Diagnostics.Process[] GetProcesses (string machineName);
static member GetProcesses : string -> System.Diagnostics.Process[]
[<System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member GetProcesses : string -> System.Diagnostics.Process[]
Public Shared Function GetProcesses (machineName As String) As Process()

매개 변수

machineName
String

프로세스 목록을 읽어 올 컴퓨터입니다.

반환

지정된 컴퓨터에서 실행 중인 모든 프로세스 리소스를 나타내는 Process 형식의 배열입니다.

특성

예외

machineName 매개 변수 구문이 잘못되었습니다. 길이가 0일 수 있습니다.

machineName 매개 변수가 null인 경우

운영 체제 플랫폼이 원격 컴퓨터에서 이 작업을 지원하지 않습니다.

프로세스 정보를 가져오는 데 사용되는 성능 카운터 API에 액세스하는 데 문제가 있습니다. 이 예외는 Windows NT, Windows 2000 및 Windows XP에 해당됩니다.

내부 시스템 API에 액세스하는 동안 문제가 발생했습니다.

예제

다음 예제에서는 현재 프로세스의 정보, 로컬 컴퓨터에서 실행되는 프로세스, 로컬 컴퓨터에서 실행되는 메모장의 모든 인스턴스 및 로컬 컴퓨터의 특정 프로세스를 검색합니다. 그런 다음 원격 컴퓨터에서 동일한 프로세스에 대한 정보를 검색합니다.

#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.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

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

    End Class

End Namespace 'MyProcessSample

설명

이 메서드를 사용하여 새 Process 구성 요소의 배열을 만들고 지정된(일반적으로 원격) 컴퓨터의 모든 프로세스 리소스와 연결합니다. 때문에 로컬 컴퓨터의 프로세스 리소스에 이미 존재 해야 합니다 GetProcesses 시스템 리소스를 만들지는 않지만 대신 애플리케이션에서 생성 된 리소스를 연결 Process 구성 요소입니다. 운영 체제 자체가 백그라운드 프로세스를 실행하고 있으므로 이 배열은 비어 있지 않습니다.

컴퓨터에서 실행되는 모든 프로세스를 검색하지 않으려면 또는 GetProcessesByName 메서드를 사용하여 GetProcessById 해당 프로세스를 제한할 수 있습니다. GetProcessById 는 메서드에 Process 전달하는 프로세스 식별자에 의해 시스템에서 식별된 프로세스와 연결된 구성 요소를 만듭니다. GetProcessesByName 는 연결된 프로세스 리소스가 메서드에 전달하는 실행 파일을 공유하는 구성 요소의 배열 Process 을 만듭니다.

메서드의 GetProcesses 이 오버로드는 일반적으로 네트워크의 원격 컴퓨터에서 실행되는 프로세스 리소스 목록을 검색하는 데 사용되지만 "."를 전달하여 로컬 컴퓨터를 지정할 수 있습니다.

참고

여러 Windows 서비스는 svchost.exe(서비스 호스트 프로세스)의 동일한 instance 내에 로드할 수 있습니다. GetProcesses는 이러한 개별 서비스를 식별하지 않습니다. 이 경우 을 참조하세요 GetServices.

추가 정보

적용 대상