ServiceController.ServicesDependedOn 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
此服务所依赖的服务集。
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 服务未运行,将无法启动此服务。