ServiceController.DependentServices 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取依赖于与此 ServiceController 实例关联的服务的服务集。
public:
property cli::array <System::ServiceProcess::ServiceController ^> ^ DependentServices { cli::array <System::ServiceProcess::ServiceController ^> ^ get(); };
public System.ServiceProcess.ServiceController[] DependentServices { get; }
[System.ServiceProcess.ServiceProcessDescription("SPDependentServices")]
public System.ServiceProcess.ServiceController[] DependentServices { get; }
member this.DependentServices : System.ServiceProcess.ServiceController[]
[<System.ServiceProcess.ServiceProcessDescription("SPDependentServices")>]
member this.DependentServices : System.ServiceProcess.ServiceController[]
Public ReadOnly Property DependentServices As ServiceController()
属性值
ServiceController 实例的数组,其中每个数组均与依赖于此服务的一个服务关联。
- 属性
例外
访问 API 时出错。
未找到服务。
示例
以下示例使用 ServiceController 类显示依赖于事件日志服务的一组服务。
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
注解
如果应用程序调用Stop此服务,则数组DependentServices表示系统停止的服务。