Export (0) Print
Expand All

ServiceController.DependentServices Property

Gets the set of services that depends on the service associated with this ServiceController instance.

Namespace: System.ServiceProcess
Assembly: System.ServiceProcess (in system.serviceprocess.dll)

'Declaration
Public ReadOnly Property DependentServices As ServiceController()
'Usage
Dim instance As ServiceController
Dim value As ServiceController()

value = instance.DependentServices

/** @property */
public ServiceController[] get_DependentServices ()

public function get DependentServices () : ServiceController[]

Property Value

An array of ServiceController instances, each of which is associated with a service that depends on this service.

Exception typeCondition

Win32Exception

An error occurred when accessing a system API.

The DependentServices array represents the services that the system stops if your application calls Stop for this service.

The following example uses the ServiceController class to display the set of services that are dependent on the Event Log service.


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


ServiceController sc = new ServiceController("Event Log");
ServiceController scServices[] = sc.get_DependentServices();
// Display the list of services dependent on the Event Log service.
if (scServices.get_Length() == 0) {
    Console.WriteLine("There are no services dependent on {0}",
        sc.get_ServiceName());
}
else {
    Console.WriteLine("Services dependent on {0}:", 
        sc.get_ServiceName());
    ServiceController scTemp = new ServiceController();
    for  (int iCtr = 0; iCtr < scServices.get_Length(); iCtr++) {
        scTemp = scServices[iCtr];
        Console.WriteLine(" {0}", scTemp.get_DisplayName());
    }
}

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft