Platform SDK: DLLs, Processes, and Threads |
The EnumDependentServices function retrieves the name and status of each service that depends on the specified service; that is, the specified service must be running before the dependent services can run.
BOOL EnumDependentServices( SC_HANDLE hService, // handle to service DWORD dwServiceState, // service state LPENUM_SERVICE_STATUS lpServices, // status buffer DWORD cbBufSize, // size of status buffer LPDWORD pcbBytesNeeded, // buffer size needed LPDWORD lpServicesReturned // number of entries returned );
Value | Meaning |
---|---|
SERVICE_ACTIVE | Enumerates services that are in the following states: SERVICE_START_PENDING, SERVICE_STOP_PENDING, SERVICE_RUNNING, SERVICE_CONTINUE_PENDING, SERVICE_PAUSE_PENDING, and SERVICE_PAUSED. |
SERVICE_INACTIVE | Enumerates services that are in the SERVICE_STOPPED state. |
SERVICE_STATE_ALL | Combines the following states: SERVICE_ACTIVE and SERVICE_INACTIVE. |
The order of the services in this array is the reverse of the start order of the services. In other words, the first service in the array is the one that would be started last, and the last service in the array is the one that would be started first.
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
The following error codes may be set by the service control manager. Other error codes may be set by the registry functions that are called by the service control manager.
Error code | Meaning |
---|---|
ERROR_ACCESS_DENIED | The specified handle was not opened with SERVICE_ENUMERATE_DEPENDENTS access. |
ERROR_INVALID_HANDLE | The specified handle is invalid. |
ERROR_INVALID_PARAMETER | A parameter that was specified is invalid. |
ERROR_MORE_DATA | The buffer pointed to by lpServices is not large enough. The function sets the variable pointed to by lpServicesReturned to the actual number of service entries stored into the buffer. The function sets the variable pointed to by pcbBytesNeeded to the number of bytes required to store all of the service entries. |
The returned services entries are ordered in the reverse order of the start order, with group order taken into account. If you need to stop the dependent services, you can use the order of entries written to the lpServices buffer to stop the dependent services in the proper order.
Windows NT/2000: Requires Windows NT 3.1 or later.
Header: Declared in Winsvc.h; include Windows.h.
Library: Use Advapi32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
Services Overview, Service Functions, CreateService, ENUM_SERVICE_STATUS, EnumServicesStatus, OpenService