BOOL ControlService(hService, dwControl, lpServiceStatus) | |||
SC_HANDLE hService; | |||
DWORD dwControl; | |||
LPSERVICE_STATUS lpServiceStatus; |
The ControlService function sends a control to a service.
hService
Handle obtained from a previous CreateService or OpenService call.
dwControl
Value which indicates the requested control.
Value | Meaning |
SERVICE_CONTROL_STOP | requests the service to stop. |
SERVICE_CONTROL_PAUSE | requests the service to pause. |
SERVICE_CONTROL_CONTINUE | requests the paused service to resume. |
SERVICE_CONTROL_INTERROGATE | requests that the service updates the Service Control Manager of its status information immediately. |
lpServiceStatus
A pointer to a buffer to receive a SERVICE_STATUS information structure. This information reflects the latest status of the service in response to the requested control.
Returns TRUE if the service has responded to the control by returning its service status information. If the return value is FALSE, an error has occurred. Use GetLastError to determine the cause of the failure.
Errors | Value | Meaning | |
ERROR_ACCESS_DENIED | |||
The specified handle was not opened with control access requested. | |||
ERROR_DEPENDENT_SERVICES_RUNNING | |||
A stop control has been sent to the service which other running services are dependent on. | |||
ERROR_SERVICE_REQUEST_TIMEOUT | |||
The service did not respond to the start request in a timely fashion. | |||
ERROR_INVALID_SERVICE_CONTROL | |||
The requested control is not valid, or is unacceptable to the service. | |||
ERROR_SERVICE_CANNOT_ACCEPT_CTRL | |||
The requested control cannot be sent to the service because the state of the service is stopped, stop-pending, or start-pending. |
This function asks the Service Control Manager to send the requested control to the service. The control is sent if the service accepts the control, and the service is in a controllable state (see table in section 3.4). All services accept SERVICE_CONTROL_INTERROGATE by default, and may or may not accept the rest of the controls.