Platform SDK: DLLs, Processes, and Threads |
The EnumServicesStatusEx function enumerates services in the specified service control manager database. The name and status of each service are provided, along with additional data based on the specified information level.
This function supersedes the EnumServicesStatus 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 EnumServicesStatusEx ( SC_HANDLE hSCManager, // handle to SCM database SC_ENUM_TYPE InfoLevel, // information level DWORD dwServiceType, // service type DWORD dwServiceState, // service state LPBYTE lpServices, // status buffer DWORD cbBufSize, // size of status buffer LPDWORD pcbBytesNeeded, // buffer size needed LPDWORD lpServicesReturned, // number of entries returned LPDWORD lpResumeHandle, // next entry LPCTSTR pszGroupName // load-order group name );
Currently, no other information levels are defined.
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 SERVICE_ACTIVE and SERVICE_INACTIVE states. |
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 errors may be returned.
Error code | Meaning | |
---|---|---|
ERROR_ACCESS_DENIED | The handle was not opened with SC_MANAGER_ENUMERATE_SERVICE access. | |
ERROR_MORE_DATA | The buffer is too small. Not all data in the active database could be returned. The pcbBytesNeeded parameter contains the number of bytes required to receive the remaining entries. | |
ERROR_INVALID_PARAMETER | An illegal parameter value was used. | |
ERROR_INVALID_HANDLE | The handle is invalid. | |
ERROR_INVALID_LEVEL | The InfoLevel parameter contains an unsupported value. | |
ERROR_SHUTDOWN_IN_PROGRESS | The system is shutting down; this function cannot be called. |
Windows NT/2000: Requires Windows 2000.
Header: Declared in Winsvc.h; include Windows.h.
Library: Use Advapi32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows 2000.
Services Overview, Service Functions, ENUM_SERVICE_STATUS_PROCESS