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.
Syntax
BOOL WINAPI EnumServicesStatusEx( _In_ SC_HANDLE hSCManager, _In_ SC_ENUM_TYPE InfoLevel, _In_ DWORD dwServiceType, _In_ DWORD dwServiceState, _Out_opt_ LPBYTE lpServices, _In_ DWORD cbBufSize, _Out_ LPDWORD pcbBytesNeeded, _Out_ LPDWORD lpServicesReturned, _Inout_opt_ LPDWORD lpResumeHandle, _In_opt_ LPCTSTR pszGroupName );
Parameters
- hSCManager [in]
-
A handle to the service control manager database. This handle is returned by the OpenSCManager function, and must have the SC_MANAGER_ENUMERATE_SERVICE access right. For more information, see Service Security and Access Rights.
- InfoLevel [in]
-
The service attributes that are to be returned. Use SC_ENUM_PROCESS_INFO to retrieve the name and service status information for each service in the database. The lpServices parameter is a pointer to a buffer that receives an array of ENUM_SERVICE_STATUS_PROCESS structures. The buffer must be large enough to hold the structures as well as the strings to which their members point.
Currently, no other information levels are defined.
- dwServiceType [in]
-
The type of services to be enumerated. This parameter can be one or more of the following values.
Value Meaning - SERVICE_DRIVER
- 0x0000000B
Services of type SERVICE_KERNEL_DRIVER and SERVICE_FILE_SYSTEM_DRIVER.
- SERVICE_FILE_SYSTEM_DRIVER
- 0x00000002
File system driver services.
- SERVICE_KERNEL_DRIVER
- 0x00000001
Driver services.
- SERVICE_WIN32
- 0x00000030
Services of type SERVICE_WIN32_OWN_PROCESS and SERVICE_WIN32_SHARE_PROCESS.
- SERVICE_WIN32_OWN_PROCESS
- 0x00000010
Services that run in their own processes.
- SERVICE_WIN32_SHARE_PROCESS
- 0x00000020
Services that share a process with one or more other services. For more information, see Service Programs.
- dwServiceState [in]
-
The state of the services to be enumerated. This parameter can be one of the following values.
- lpServices [out, optional]
-
A pointer to the buffer that receives the status information. The format of this data depends on the value of the InfoLevel parameter.
The maximum size of this array is 256K bytes. To determine the required size, specify NULL for this parameter and 0 for the cbBufSize parameter. The function will fail and GetLastError will return ERROR_MORE_DATA. The pcbBytesNeeded parameter will receive the required size.
Windows Server 2003 and Windows XP: The maximum size of this array is 64K bytes. This limit was increased as of Windows Server 2003 with SP1 and Windows XP with SP2.
- cbBufSize [in]
-
The size of the buffer pointed to by the lpServices parameter, in bytes.
- pcbBytesNeeded [out]
-
A pointer to a variable that receives the number of bytes needed to return the remaining service entries, if the buffer is too small.
- lpServicesReturned [out]
-
A pointer to a variable that receives the number of service entries returned.
- lpResumeHandle [in, out, optional]
-
A pointer to a variable that, on input, specifies the starting point of enumeration. You must set this value to zero the first time the EnumServicesStatusEx function is called. On output, this value is zero if the function succeeds. However, if the function returns zero and the GetLastError function returns ERROR_MORE_DATA, this value indicates the next service entry to be read when the EnumServicesStatusEx function is called to retrieve the additional data.
- pszGroupName [in, optional]
-
The load-order group name. If this parameter is a string, the only services enumerated are those that belong to the group that has the name specified by the string. If this parameter is an empty string, only services that do not belong to any group are enumerated. If this parameter is NULL, group membership is ignored and all services are enumerated.
Return value
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.
| Return code | Description |
|---|---|
|
The handle does not have the SC_MANAGER_ENUMERATE_SERVICE access right. |
|
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. |
|
An illegal parameter value was used. |
|
The handle is invalid. |
|
The InfoLevel parameter contains an unsupported value. |
|
The system is shutting down; this function cannot be called. |
Remarks
If the caller does not have the SERVICE_QUERY_STATUS access right to a service, the service is silently omitted from the list of services returned to the client.
Requirements
|
Minimum supported client |
Windows XP [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows Server 2003 [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names |
EnumServicesStatusExW (Unicode) and EnumServicesStatusExA (ANSI) |
See also