ServiceType 列挙型

定義

サービスの型を表します。Represents the type of the service.

この列挙体には FlagsAttribute 属性があり、そのメンバー値のビットごとの組み合わせが可能になります。

public enum class ServiceType
[System.Flags]
public enum ServiceType
[<System.Flags>]
type ServiceType = 
Public Enum ServiceType
継承
ServiceType
属性

フィールド

Adapter 4

独自のドライバーが必要なハードウェア デバイス向けのサービス。A service for a hardware device that requires its own driver.

FileSystemDriver 2

カーネル デバイス ドライバーでもあるファイル システム ドライバー。A file system driver, which is also a Kernel device driver.

InteractiveProcess 256

デスクトップと通信できるサービス。A service that can communicate with the desktop.

KernelDriver 1

ハード ディスクやその他のロー レベルのハードウェア デバイス ドライバーなどのカーネル デバイス ドライバー。A Kernel device driver such as a hard disk or other low-level hardware device driver.

RecognizerDriver 8

起動中にシステム上でファイル システムの存在を確認するファイル システム ドライバー。A file system driver used during startup to determine the file systems present on the system.

Win32OwnProcess 16

サービス コントローラーにより開始可能で、サービス制御プロトコルに従う Win32 プログラム。A Win32 program that can be started by the Service Controller and that obeys the service control protocol. この種類の Win32 サービスは独自のプロセスで実行されます。This type of Win32 service runs in a process by itself.

Win32ShareProcess 32

他の Win32 サービスとのプロセス共有が可能な Win32 サービス。A Win32 service that can share a process with other Win32 services.

次の例では、クラスを使用して、 ServiceController ローカルコンピューターのデバイスドライバーサービスを表示します。The following example uses the ServiceController class to display the device driver services on the local computer.

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)

注釈

サービスの種類は、サービスがシステムによってどのように使用されるかを示します。The service type indicates how the service is used by the system. ServiceControllerサービスにコマンドを渡すは、サービスの種類の値を格納します。The ServiceController that passes commands to the service stores a value for the service type.

ServiceType インスタンスの値は、ビットごとの OR 演算子を使用して組み合わされた一連のフラグを表します。The value of a ServiceType instance represents a set of flags combined using the bitwise OR operator.

対話型サービスの作成はサポートされていません。The creation of interactive services is not supported. これを回避するには、非対話型サービスと、ソケットまたはリモート処理を使用してサービスと通信する独立したコントロール GUI アプリケーションを作成します。To workaround this, you can create a non-interactive service and a separate control GUI application that communicates with the service using sockets or remoting.

適用対象

こちらもご覧ください