ServiceController.DependentServices Property
Gets the set of services that depends on the service associated with this ServiceController instance.
[Visual Basic] Public ReadOnly Property DependentServices As ServiceController () [C#] public ServiceController[] DependentServices {get;} [C++] public: __property ServiceController* get_DependentServices(); [JScript] 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.
Exceptions
| Exception Type | Condition |
|---|---|
| Win32Exception | An error occurred when accessing a system API. |
Remarks
The DependentServices array represents the services that the system stops if your application calls Stop for this service.
Example
[Visual Basic, C#, C++] The following example uses the ServiceController class to display the set of services that are dependent on the Event Log service.
[Visual Basic] 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 [C#] 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); } } [C++] ServiceController *sc = new ServiceController("Event Log"); ServiceController * scServices[] = 0; 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 (int i=0; i<scServices->Length; i++) { ServiceController *scTemp = scServices[i]; Console::WriteLine(" {0}", scTemp->DisplayName); } } }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
.NET Framework Security:
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries From Partially Trusted Code
See Also
ServiceController Class | ServiceController Members | System.ServiceProcess Namespace