ServiceController.DisplayName ServiceController.DisplayName ServiceController.DisplayName ServiceController.DisplayName Property

Definizione

Ottiene o imposta un nome descrittivo per il servizio.Gets or sets a friendly name for the service.

public:
 property System::String ^ DisplayName { System::String ^ get(); void set(System::String ^ value); };
[System.ServiceProcess.ServiceProcessDescription("SPDisplayName")]
public string DisplayName { get; set; }
member this.DisplayName : string with get, set
Public Property DisplayName As String

Valore della proprietà

Nome descrittivo del servizio, che può essere usato per identificare il servizio.The friendly name of the service, which can be used to identify the service.

Eccezioni

Si è verificato un errore durante l'accesso a un'API di sistema.An error occurred when accessing a system API.

Esempi

L'esempio seguente usa il ServiceController classe per visualizzare il set di servizi che dipendono dal servizio Log eventi.The following example uses the ServiceController class to display the set of services that are dependent on the Event Log service.

ServiceController^ sc = gcnew ServiceController(  "Event Log" );
array<ServiceController^>^scServices = nullptr;
if ( sc )
{
   scServices = sc->DependentServices;
}

if ( sc && scServices )
{
   // Display the list of services dependent on the Event Log service.
   if ( scServices->Length == 0 )
   {
      Console::WriteLine(  "There are no services dependent on {0}", sc->ServiceName );
   }
   else
   {
      Console::WriteLine(  "Services dependent on {0}:", sc->ServiceName );
      for each (ServiceController^ scTemp in scServices)
      {
         Console::WriteLine(" {0}", scTemp->DisplayName);
      }
   }
}

ServiceController sc =  new ServiceController("Event Log");
ServiceController[] scServices = sc.DependentServices;

// Display the list of services dependent on the Event Log service.
if (scServices.Length == 0)
{
   Console.WriteLine("There are no services dependent on {0}", 
                      sc.ServiceName);
}
else 
{
   Console.WriteLine("Services dependent on {0}:",
                      sc.ServiceName);

   foreach (ServiceController scTemp in scServices)
   {
      Console.WriteLine(" {0}", scTemp.DisplayName);
   }
}


Dim sc As New ServiceController("Event Log")
Dim scServices As ServiceController() = sc.DependentServices

' Display the list of services dependent on the Event Log service.
If scServices.Length = 0 Then
   Console.WriteLine("There are no services dependent on {0}", sc.ServiceName)
Else
   Console.WriteLine("Services dependent on {0}:", sc.ServiceName)
   
   Dim scTemp As ServiceController
   For Each scTemp In  scServices
      Console.WriteLine(" {0}", scTemp.DisplayName)
   Next scTemp
End If

Commenti

È possibile impostare il DisplayName su una stringa vuota (""), ma impostare la proprietà su null genera un'eccezione.You can set the DisplayName to an empty string (""), but setting the property to null throws an exception.

Si applica a