Platform SDK: DLLs, Processes, and Threads |
The QueryServiceStatusEx function retrieves the current status of the specified service based on the specified information level.
This function supersedes the QueryServiceStatus function. QueryServiceStatusEx returns the same information QueryServiceStatus returns, with the addition of the process identifier and additional flags for the service.
BOOL QueryServiceStatusEx( SC_HANDLE hService, // handle to service SC_STATUS_TYPE InfoLevel, // information level LPBYTE lpBuffer, // buffer DWORD cbBufSize, // size of buffer LPDWORD pcbBytesNeeded // bytes needed );
Currently, no other information levels are defined.
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 can be returned.
Error code | Meaning |
---|---|
ERROR_INVALID_HANDLE | The handle is invalid. |
ERROR_ACCESS_DENIED | The handle was not opened with SERVICE_QUERY_STATUS access. |
ERROR_INSUFFICIENT_BUFFER | The buffer is too small for the SERVICE_STATUS_PROCESS structure. Nothing was written to the structure. |
ERROR_INVALID_PARAMETER | The cbSize member of SERVICE_STATUS_PROCESS is not valid. |
ERROR_INVALID_LEVEL | The InfoLevel parameter contains an unsupported value. |
ERROR_SHUTDOWN_IN_PROGRESS | The system is shutting down; this function cannot be called. |
The QueryServiceStatusEx function returns the most recent service status information reported to the service control manager. If the service just changed its status, it may not have updated the service control manager yet. Applications can find the current service status by querying the service directly by using the ControlService function with the SERVICE_CONTROL_INTERROGATE control code.
Windows NT/2000: Requires Windows 2000.
Header: Declared in Winsvc.h; include Windows.h.
Library: Use Advapi32.lib.
Services Overview, Service Functions, SERVICE_STATUS_PROCESS