Skip to content

ServiceControlCodeConstants

The control codes the SCM can deliver to a running service. Used as the dwControl parameter of ITbService.ChangeState (where the service reacts to the request) and as the ControlCode parameter of Services.ControlService (where the consumer issues the request to a service running elsewhere).

The values mirror the Win32 SERVICE_CONTROL_* constants verbatim --- the vb prefix is a historical hold-over from VB6's coding conventions and does not affect the numeric values.

ConstantValueDescription
vbServiceControlStop0x01Request the service stop. The standard shutdown signal --- every service should handle this in ChangeState.
vbServiceControlPause0x02Pause the service. Only delivered if ServiceManager.SupportsPausing is True.
vbServiceControlContinue0x03Resume a paused service. Paired with vbServiceControlPause.
vbServiceControlInterrogate0x04The SCM is asking the service to re-report its current state via ReportStatus. A bare-minimum handler can ignore it --- the SCM already has the most recent status from the previous call.
vbServiceControlShutdown0x05The OS is shutting down. Most services treat this identically to vbServiceControlStop.
vbServiceControlParamChange0x06An admin has changed the service's configuration via sc.exe config. Delivered only if the service registered SERVICE_ACCEPT_PARAMCHANGE --- currently not exposed through the package.
vbServiceControlNetBindAdd0x07A new network binding is available. Delivered only if SERVICE_ACCEPT_NETBINDCHANGE is accepted --- currently not exposed.
vbServiceControlNetBindRemove0x08A network binding has been removed.
vbServiceControlNetBindEnable0x09A previously disabled network binding has been enabled.
vbServiceControlNetBindDisable0x0AA network binding has been disabled.
vbServiceControlDeviceEvent0x0BA device-arrival / -removal event. The dwEventType and lpEventData parameters of ChangeState hold the DBT_* sub-code and DEV_BROADCAST_HDR data. Only delivered when the service has accepted SERVICE_ACCEPT_HARDWAREPROFILECHANGE.
vbServiceControlHardwareProfileChange0x0CA hardware-profile change (laptop docking, …).
vbServiceControlPowerEvent0x0DA system power event (suspend, resume, battery low, …). The dwEventType parameter holds the PBT_* sub-code.
vbServiceControlSessionChange0x0EA session-change event (user logon, RDP connect / disconnect, …). The dwEventType parameter holds the WTS_* sub-code.
vbServiceControlPreShutdown0x0FThe OS is about to shut down --- sent before vbServiceControlShutdown to services that have registered for the longer pre-shutdown notification window.
vbServiceControlTimeChange0x10The system time has changed.
vbServiceControlTriggerEvent0x20A registered trigger event has fired (typically used by trigger-started services).
vbServiceControlLowResources0x60The service should reduce its memory / CPU footprint.
vbServiceControlSystemLowResources0x61The whole system is low on resources.

Control codes in the range 128--255 are reserved for user-defined codes; pass any value in that range to Services.ControlService and the package will request the matching SERVICE_USER_DEFINED_CONTROL SCM permission. Most services only need to handle vbServiceControlStop and optionally the pause / continue pair.

twinBASIC and LOGO copyright of "WaynePhillipsEA" author