Sends a stop request to the specified service.

StopService(cServiceName | nServiceHandle [, nTimeout [, bStopDependantServices [, cServer [, cDatabase]]]])

Parameters

cServiceName | nServiceHandle

Either the name of the service or a numeric handle returned from the OpenService function.

nTimeout (optional)

Maximum time in seconds to wait while the service is in SERVICE_STOP_PENDING state.

If you pass 0 the function doesn't wait until the service stopped but instead returns immeditely after the stop request has been send.

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.

bStopDependantServices (optional)

default = .F.

If .T. services that are dependant on the passed service are stopped first.

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 was stopped successful or was already stopped, 0 if the timeout interval elapsed before the service switched into the stopped state.

See Also

Reference

ADependentServices
AServiceConfig
AServices
AServiceStatus
CloseServiceHandle
ContinueService
ControlService
CreateService
OpenService
PauseService
StartService
WaitForServiceStatus

Used WinApi functions

ControlService
EnumDependentServices
QueryServiceStatus
OpenSCManager
OpenService