ServiceType ServiceType ServiceType ServiceType Enum

Definizione

Rappresenta il tipo del servizio.Represents the type of the service.

Questa enumerazione ha un attributo FlagsAttribute che consente una combinazione bit per bit dei valori del relativo membro.

public enum class ServiceType
[System.Flags]
public enum ServiceType
type ServiceType = 
Public Enum ServiceType
Ereditarietà
Attributi

Campi

Adapter Adapter Adapter Adapter 4

Servizio per una periferica che richiede un driver apposito.A service for a hardware device that requires its own driver.

FileSystemDriver FileSystemDriver FileSystemDriver FileSystemDriver 2

Driver del file system, che è anche un driver di periferica Kernel.A file system driver, which is also a Kernel device driver.

InteractiveProcess InteractiveProcess InteractiveProcess InteractiveProcess 256

Servizio in grado di comunicare con il desktop.A service that can communicate with the desktop.

KernelDriver KernelDriver KernelDriver KernelDriver 1

Driver di periferica Kernel, ad esempio il driver del disco rigido o di un'altra periferica di basso livello.A Kernel device driver such as a hard disk or other low-level hardware device driver.

RecognizerDriver RecognizerDriver RecognizerDriver RecognizerDriver 8

Driver di file system utilizzato durante l'avvio per determinare i file system presenti nel sistema.A file system driver used during startup to determine the file systems present on the system.

Win32OwnProcess Win32OwnProcess Win32OwnProcess Win32OwnProcess 16

Programma Win32 che può essere avviato dal Service Controller e che obbedisce al protocollo di controllo del servizio.A Win32 program that can be started by the Service Controller and that obeys the service control protocol. Questo tipo di servizio Win32 viene eseguito autonomamente in un processo.This type of Win32 service runs in a process by itself.

Win32ShareProcess Win32ShareProcess Win32ShareProcess Win32ShareProcess 32

Servizio Win32 che può condividere un processo con altri servizi Win32.A Win32 service that can share a process with other Win32 services.

Esempi

Nell'esempio seguente viene utilizzata ServiceController la classe per visualizzare i servizi del driver di dispositivo nel computer locale.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)

Commenti

Il tipo di servizio indica il modo in cui il servizio viene utilizzato dal sistema.The service type indicates how the service is used by the system. Il ServiceController che passa i comandi al servizio archivia un valore per il tipo di servizio.The ServiceController that passes commands to the service stores a value for the service type.

Il valore di un'istanza ServiceType rappresenta un set di flag combinati utilizzando l'operatore OR bit per bit.The value of a ServiceType instance represents a set of flags combined using the bitwise OR operator.

La creazione di servizi interattivi non è supportata.The creation of interactive services is not supported. Per risolvere questo problema, è possibile creare un servizio non interattivo e un'applicazione GUI di controllo separata che comunica con il servizio usando socket o servizi remoti.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.

Si applica a

Vedi anche