ServiceController.DisplayName Właściwość

Definicja

Pobiera lub ustawia przyjazną nazwę usługi.

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

Wartość właściwości

Przyjazna nazwa usługi, która może służyć do identyfikowania usługi.

Atrybuty

Wyjątki

Wartość DisplayName to null.

Wystąpił błąd podczas uzyskiwania dostępu do interfejsu API systemu.

Nie można odnaleźć usługi.

Przykłady

W poniższym przykładzie użyto ServiceController klasy , aby wyświetlić zestaw usług zależnych od usługi dziennika zdarzeń.

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

Uwagi

Można ustawić DisplayName wartość na pusty ciąg (""), ale ustawienie właściwości w celu null zgłoszenia wyjątku.

Dotyczy