共用方式為


ServiceController.ServicesDependedOn 屬性

定義

這項服務依賴的服務集。

public:
 property cli::array <System::ServiceProcess::ServiceController ^> ^ ServicesDependedOn { cli::array <System::ServiceProcess::ServiceController ^> ^ get(); };
public System.ServiceProcess.ServiceController[] ServicesDependedOn { get; }
[System.ServiceProcess.ServiceProcessDescription("SPServicesDependedOn")]
public System.ServiceProcess.ServiceController[] ServicesDependedOn { get; }
member this.ServicesDependedOn : System.ServiceProcess.ServiceController[]
[<System.ServiceProcess.ServiceProcessDescription("SPServicesDependedOn")>]
member this.ServicesDependedOn : System.ServiceProcess.ServiceController[]
Public ReadOnly Property ServicesDependedOn As ServiceController()

屬性值

ServiceController 執行個體的陣列,其中每一執行個體都與必須執行才能讓這項服務執行的服務相關聯。

屬性

例外狀況

存取系統 API 時發生的錯誤。

找不到服務。

範例

下列範例會 ServiceController 使用 類別來顯示 Messenger 服務相依的服務集。

ServiceController^ sc = gcnew ServiceController(  "Messenger" );
array<ServiceController^>^scServices = nullptr;
if ( sc )
{
   scServices = sc->ServicesDependedOn;
}

if ( sc && scServices )
{
   // Display the services that the Messenger service is dependent on.
   if ( scServices->Length == 0 )
   {
      Console::WriteLine(  "{0} service is not dependent on any other services.", sc->ServiceName );
   }
   else
   {
      Console::WriteLine(  "{0} service is dependent on the following:", sc->ServiceName );
      for each (ServiceController^ scTemp in scServices)
      {
         Console::WriteLine(" {0}", scTemp->DisplayName);
      }
   }
}
ServiceController sc = new ServiceController("Messenger");
ServiceController[] scServices= sc.ServicesDependedOn;

// Display the services that the Messenger service is dependent on.
if (scServices.Length == 0)
{
   Console.WriteLine("{0} service is not dependent on any other services.",
                      sc.ServiceName);
}
else
{
   Console.WriteLine("{0} service is dependent on the following:",
                      sc.ServiceName);

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

Dim sc As New ServiceController("Messenger")
Dim scServices As ServiceController() = sc.ServicesDependedOn

' Display the services that the Messenger service is dependent on.
If scServices.Length = 0 Then
   Console.WriteLine("{0} service is not dependent on any other services.", sc.ServiceName)
Else
   Console.WriteLine("{0} service is dependent on the following:", sc.ServiceName)
   
   Dim scTemp As ServiceController
   For Each scTemp In  scServices
      Console.WriteLine(" {0}", scTemp.DisplayName)
   Next scTemp
End If

備註

如果陣列中的任何 ServicesDependedOn 服務未執行,您將無法啟動此服務。

適用於