Platform SDK: DLLs, Processes, and Threads |
The EnumServicesStatus function enumerates services in the specified service control manager database. The name and status of each service are provided.
This function has been superseded by the EnumServicesStatusEx function. It returns the same information EnumServicesStatus returns, plus the process identifier and additional flags for the service. In addition, EnumServicesStatusEx enables you to enumerate services that belong to a specified group.
BOOL EnumServicesStatus( SC_HANDLE hSCManager, // handle to SCM database DWORD dwServiceType, // service type 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 LPDWORD lpResumeHandle // next entry );
Value | Meaning |
---|---|
SERVICE_WIN32 | Enumerates services of type SERVICE_WIN32_OWN_PROCESS and SERVICE_WIN32_SHARE_PROCESS. |
SERVICE_DRIVER | Enumerates services of type SERVICE_KERNEL_DRIVER and SERVICE_FILE_SYSTEM_DRIVER. |
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. |
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 can be set by the service control manager. Other error codes can 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 SC_MANAGER_ENUMERATE_SERVICE access. |
ERROR_INVALID_HANDLE | The specified handle is invalid. |
ERROR_INVALID_PARAMETER | A parameter that was specified is invalid. |
ERROR_MORE_DATA | There are more service entries than would fit into the lpServices buffer. The actual number of service entries written to lpServices is returned in the lpServicesReturned parameter. The number of bytes required to get the remaining entries is returned in the pcbBytesNeeded parameter. The remaining services can be enumerated by additional calls to EnumServicesStatus with the lpResumeHandle parameter indicating the next service to read. |
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, EnumDependentServices, EnumServicesStatusEx, ENUM_SERVICE_STATUS, OpenSCManager