ServiceController.GetDevices 메서드

정의

컴퓨터에서 디바이스 드라이버 서비스를 검색합니다.

오버로드

GetDevices()

로컬 컴퓨터에서 디바이스 드라이버 서비스를 검색합니다.

GetDevices(String)

지정된 컴퓨터에서 디바이스 드라이버 서비스를 검색합니다.

GetDevices()

로컬 컴퓨터에서 디바이스 드라이버 서비스를 검색합니다.

public:
 static cli::array <System::ServiceProcess::ServiceController ^> ^ GetDevices();
public static System.ServiceProcess.ServiceController[] GetDevices ();
static member GetDevices : unit -> System.ServiceProcess.ServiceController[]
Public Shared Function GetDevices () As ServiceController()

반환

ServiceController[]

각 요소가 로컬 컴퓨터에 있는 디바이스 드라이버 서비스와 관련된 ServiceController 형식의 배열입니다.

예외

시스템 API에 액세스할 때 오류가 발생했습니다.

예제

다음 예제에서는 ServiceController 로컬 컴퓨터에 디바이스 드라이버 서비스를 표시 하는 클래스입니다.

array<ServiceController^>^scDevices = ServiceController::GetDevices();
if ( scDevices->Length )
{
   int numAdapter = 0,numFileSystem = 0,numKernel = 0,numRecognizer = 0;

   // Display the list of device driver services.
   Console::WriteLine(  "Device driver services on the local computer:" );

   for each (ServiceController^ scTemp in scDevices)
   {
      // Display the status and the service name, for example,
      //   [Running] PCI Bus Driver
      //             Type = KernelDriver
      Console::WriteLine(  " [{0}] {1}", scTemp->Status, scTemp->DisplayName );
      Console::WriteLine(  "           Type = {0}", scTemp->ServiceType );

      // Update counters using the service type bit flags.
      if ( (scTemp->ServiceType & ServiceType::Adapter) != (ServiceType)0 )
      {
         numAdapter++;
      }
      if ( (scTemp->ServiceType & ServiceType::FileSystemDriver) != (ServiceType)0 )
      {
         numFileSystem++;
      }
      if ( (scTemp->ServiceType & ServiceType::KernelDriver) != (ServiceType)0 )
      {
         numKernel++;
      }
      if ( (scTemp->ServiceType & ServiceType::RecognizerDriver) != (ServiceType)0 )
      {
         numRecognizer++;
      }
   }
   Console::WriteLine();
   Console::WriteLine(  "Total of {0} device driver services", scDevices->Length.ToString() );
   Console::WriteLine(  "  {0} are adapter drivers", numAdapter.ToString() );
   Console::WriteLine(  "  {0} are file system drivers", numFileSystem.ToString() );
   Console::WriteLine(  "  {0} are kernel drivers", numKernel.ToString() );
   Console::WriteLine(  "  {0} are file system recognizer drivers", numRecognizer.ToString() );
ServiceController[] scDevices;
scDevices = ServiceController.GetDevices();

int numAdapter = 0,
    numFileSystem = 0,
    numKernel = 0,
    numRecognizer = 0;

// Display the list of device driver services.
Console.WriteLine("Device driver services on the local computer:");

foreach (ServiceController scTemp in scDevices)
{
   // Display the status and the service name, for example,
   //   [Running] PCI Bus Driver
   //             Type = KernelDriver

   Console.WriteLine(" [{0}] {1}",
                     scTemp.Status, scTemp.DisplayName);
   Console.WriteLine("           Type = {0}", scTemp.ServiceType);

   // Update counters using the service type bit flags.
   if ((scTemp.ServiceType & ServiceType.Adapter) != 0)
   {
      numAdapter++;
   }
   if ((scTemp.ServiceType & ServiceType.FileSystemDriver) != 0)
   {
      numFileSystem++;
   }
   if ((scTemp.ServiceType & ServiceType.KernelDriver) != 0)
   {
      numKernel++;
   }
   if ((scTemp.ServiceType & ServiceType.RecognizerDriver) != 0)
   {
      numRecognizer++;
   }
}

Console.WriteLine();
Console.WriteLine("Total of {0} device driver services", scDevices.Length);
Console.WriteLine("  {0} are adapter drivers", numAdapter);
Console.WriteLine("  {0} are file system drivers", numFileSystem);
Console.WriteLine("  {0} are kernel drivers", numKernel);
Console.WriteLine("  {0} are file system recognizer drivers", numRecognizer);

Dim scDevices() As ServiceController
scDevices = ServiceController.GetDevices()

Dim numAdapter As Integer
Dim numFileSystem As Integer
Dim numKernel As Integer
Dim numRecognizer As Integer

' Display the list of device driver services.
Console.WriteLine("Device driver services on the local computer:")

Dim scTemp As ServiceController
For Each scTemp In  scDevices
   ' Display the status and the service name, for example,
   '   [Running] PCI Bus Driver
   '             Type = KernelDriver

   Console.WriteLine(" [{0}] {1}", scTemp.Status, scTemp.DisplayName)
   Console.WriteLine("           Type = {0}", scTemp.ServiceType)

   ' Update counters using the service type bit flags.
   If (scTemp.ServiceType And ServiceType.Adapter) <> 0 Then
      numAdapter = numAdapter + 1
   End If
   If (scTemp.ServiceType And ServiceType.FileSystemDriver) <> 0 Then
      numFileSystem = numFileSystem + 1
   End If
   If (scTemp.ServiceType And ServiceType.KernelDriver) <> 0 Then
      numKernel = numKernel + 1
   End If
   If (scTemp.ServiceType And ServiceType.RecognizerDriver) <> 0 Then
      numRecognizer = numRecognizer + 1
   End If

Next scTemp

Console.WriteLine()
Console.WriteLine("Total of {0} device driver services", scDevices.Length)
Console.WriteLine("  {0} are adapter drivers", numAdapter)
Console.WriteLine("  {0} are file system drivers", numFileSystem)
Console.WriteLine("  {0} are kernel drivers", numKernel)
Console.WriteLine("  {0} are file system recognizer drivers", numRecognizer)

설명

GetDevices 로컬 컴퓨터에서 디바이스 드라이버 서비스를 반환합니다. 드라이버가 아닌 비 디바이스 드라이버 서비스 또는 서비스를 검색하려면 메서드를 호출합니다 GetServices . 두 메서드는 함께 컴퓨터의 모든 서비스에 대한 액세스를 제공합니다.

추가 정보

적용 대상

GetDevices(String)

지정된 컴퓨터에서 디바이스 드라이버 서비스를 검색합니다.

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

매개 변수

machineName
String

디바이스 드라이버 서비스를 검색할 컴퓨터입니다.

반환

ServiceController[]

각 요소가 지정된 컴퓨터에 있는 디바이스 드라이버 서비스와 관련된 ServiceController 형식의 배열입니다.

예외

시스템 API에 액세스할 때 오류가 발생했습니다.

machineName 매개 변수 구문이 잘못된 경우.

설명

GetDevices 지정된 된 컴퓨터에서 디바이스 드라이버 서비스를 반환합니다. 드라이버가 아닌 비 디바이스 드라이버 서비스 또는 서비스를 검색하려면 메서드를 호출합니다 GetServices . 두 메서드는 함께 컴퓨터의 모든 서비스에 대한 액세스를 제공합니다.

추가 정보

적용 대상