Export (0) Print
Expand All

ServiceController.ServicesDependedOn Property

The set of services that this service depends on.

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

public:
property array<ServiceController^>^ ServicesDependedOn {
	array<ServiceController^>^ get ();
}
/** @property */
public ServiceController[] get_ServicesDependedOn ()

public function get ServicesDependedOn () : ServiceController[]

Property Value

An array of ServiceController instances, each of which is associated with a service that must be running for this service to run.

Exception typeCondition

Win32Exception

An error occurred when accessing a system API.

If any service in the ServicesDependedOn array is not running, you will not be able to start this service.

The following example uses the ServiceController class to display the set of services that the Messenger service is dependent on.

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.get_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.get_ServiceName());
}
else {
    Console.WriteLine("{0} service is dependent on the following:",
        sc.get_ServiceName());
    ServiceController scTemp = null;
    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