Monitors a windows service to reach a specified status.
WaitForServiceStatus(cServiceName | nServiceHandle, nStatus [, nTimeout [, cServer [, cDatabase]]])
Parameters
- cServiceName | nServiceHandle
Either the name of the service or a numeric handle returned from the OpenService function.
- nStatus
The service status to wait for.
One of the following values. Status Description SERVICE_STOPPED The service is not running. SERVICE_START_PENDING The service is starting. SERVICE_STOP_PENDING The service is stopping. SERVICE_RUNNING The service is running. SERVICE_CONTINUE_PENDING The service continue is pending. SERVICE_PAUSE_PENDING The service pause is pending. SERVICE_PAUSED The service is paused.
- nTimeout (optional)
Maximum time in seconds to wait while the service is in not in the requested state.
If you pass 0 as the timout value the function checks the status once and then returns immediately.
If you omit this parameter or pass NULL the timeout is set to the default timeout reported by the service.
See MSDN help for SERVICE_STATUS_PROCESS structure's "dwWaitHint" member.
- cServer (optional)
The server name on which the service is running.
See MSDN help for OpenSCManager.
- cDatabase (optional)
The database under which the service is registered.
See MSDN help for OpenSCManager.
Return Value
1 if the service is in the requested state within the timeout period, 0 if not.
See Also
Reference
ADependentServices
AServiceConfig
AServices
AServiceStatus
CloseServiceHandle
ContinueService
ControlService
CreateService
OpenService
PauseService
StartService
StopService