Skip to content

ServiceStatusConstants

The runtime-state values a service reports to the SCM through ServiceManager.ReportStatus. The same numeric values are returned by ServiceState.CurrentState (typed as a plain Long) and rendered as text by ServiceState.CurrentStateText.

The values mirror the Win32 SERVICE_* state constants. The vb prefix is a historical hold-over from VB6's coding conventions.

ConstantValueDescription
vbServiceStatusStopped1The service is not running. Set by the service immediately before EntryPoint returns; also the initial state the SCM stores when the service is registered.
vbServiceStatusStartPending2The service is starting up. Set by the package's dispatcher trampoline before it calls EntryPoint; services with long start-up sequences should also re-report this state periodically together with a WaitHint so the SCM does not declare the service hung.
vbServiceStatusStopPending3The service has acknowledged a stop request and is shutting down. Typically reported from ChangeState immediately on receipt of vbServiceControlStop.
vbServiceStatusRunning4The service has reached steady state. Reported from EntryPoint once initialisation is complete; this is what services.msc shows as "Running".
vbServiceStatusContinuePending5The service has acknowledged a continue request and is resuming. Reported from ChangeState on vbServiceControlContinue.
vbServiceStatusPausePending6The service has acknowledged a pause request. Reported from ChangeState on vbServiceControlPause.
vbServiceStatusPaused7The service has reached the paused state. Reported from EntryPoint once the pause loop is active.

The typical state sequence for a simple service: vbServiceStatusStartPending (package) → vbServiceStatusRunning (from EntryPoint) → vbServiceStatusStopPending (from ChangeState) → vbServiceStatusStopped (from EntryPoint, before returning).

twinBASIC and LOGO copyright of "WaynePhillipsEA" author