2.2.47 SERVICE_STATUS

The SERVICE_STATUS structure defines information about a service.

 typedef struct {
   DWORD dwServiceType;
   DWORD dwCurrentState;
   DWORD dwControlsAccepted;
   DWORD dwWin32ExitCode;
   DWORD dwServiceSpecificExitCode;
   DWORD dwCheckPoint;
   DWORD dwWaitHint;
 } SERVICE_STATUS,
  *LPSERVICE_STATUS;

dwServiceType: The type of service.

Value

Meaning

SERVICE_KERNEL_DRIVER

0x00000001

A driver service. These are services that manage devices on the system.

SERVICE_FILE_SYSTEM_DRIVER

0x00000002

A file system driver service. These are services that manage file systems on the system.

SERVICE_WIN32_OWN_PROCESS

0x00000010

A service that runs in its own process.

SERVICE_WIN32_SHARE_PROCESS

0x00000020

A service that shares a process with other services.

SERVICE_INTERACTIVE_PROCESS

0x00000100

The service can interact with the desktop.

Only SERVICE_WIN32_OWN_PROCESS and SERVICE_INTERACTIVE_PROCESS OR SERVICE_WIN32_SHARE_PROCESS and SERVICE_INTERACTIVE_PROCESS can be combined.

dwCurrentState: The current state of the service.

Value

Meaning

0x00000005

SERVICE_CONTINUE_PENDING

0x00000006

SERVICE_PAUSE_PENDING

0x00000007

SERVICE_PAUSED

0x00000004

SERVICE_RUNNING

0x00000002

SERVICE_START_PENDING

0x00000003

SERVICE_STOP_PENDING

0x00000001

SERVICE_STOPPED

dwControlsAccepted: The control codes that the service accepts and processes in its handler function. One or more of the following values can be set. By default, all services accept the SERVICE_CONTROL_INTERROGATE value. A value of zero indicates that no controls are accepted.

Value

Meaning

0x00000008

SERVICE_ACCEPT_PARAMCHANGE

Service can reread its startup parameters without being stopped and restarted.

This control code allows the service to receive SERVICE_CONTROL_PARAMCHANGE notifications.

0x00000002

SERVICE_ACCEPT_PAUSE_CONTINUE

Service can be paused and continued.

This control code allows the service to receive SERVICE_CONTROL_PAUSE and SERVICE_CONTROL_CONTINUE notifications.

0x00000004

SERVICE_ACCEPT_SHUTDOWN

Service is notified when system shutdown occurs.

This control code enables the service to receive SERVICE_CONTROL_SHUTDOWN notifications from the server.

0x00000001

SERVICE_ACCEPT_STOP

Service can be stopped.

This control code allows the service to receive SERVICE_CONTROL_STOP notifications.

0x00000020

SERVICE_ACCEPT_HARDWAREPROFILECHANGE

Service is notified when the computer's hardware profile changes.

0x00000040

SERVICE_ACCEPT_POWEREVENT

Service is notified when the computer's power status changes.

0x00000080

SERVICE_ACCEPT_SESSIONCHANGE

Service is notified when the computer's session status changes.

0x00000100

SERVICE_ACCEPT_PRESHUTDOWN<17>

The service can perform preshutdown tasks.

SERVICE_ACCEPT_PRESHUTDOWN is sent before sending SERVICE_CONTROL_SHUTDOWN to give more time to services that need extra time before shutdown occurs.

0x00000200

SERVICE_ACCEPT_TIMECHANGE<18>

Service is notified when the system time changes.

0x00000400

SERVICE_ACCEPT_TRIGGEREVENT<19>

Service is notified when an event for which the service has registered occurs.

dwWin32ExitCode: An error code that the service uses to report an error that occurs when it is starting or stopping. To return an error code specific to the service, the service MUST set this value to ERROR_SERVICE_SPECIFIC_ERROR to indicate that the dwServiceSpecificExitCode member contains the error code. The service sets this value to NO_ERROR when it is running and on normal termination.

dwServiceSpecificExitCode: A service-specific error code that the service returns when an error occurs while it is starting or stopping. The client SHOULD<20> ignore this value unless the dwWin32ExitCode member is set to ERROR_SERVICE_SPECIFIC_ERROR.

dwCheckPoint: A value that the service increments periodically to report its progress during a lengthy start, stop, pause, or continue operation. This value is zero when the service state is SERVICE_PAUSED, SERVICE_RUNNING, or SERVICE_STOPPED.

dwWaitHint: An estimate of the amount of time, in milliseconds, that the service expects a pending start, stop, pause, or continue operation to take before the service makes its next status update. Before the specified amount of time has elapsed, the service makes its next call to the SetServiceStatus function with either an incremented dwCheckPoint value or a change in dwCurrentState. If the time specified by dwWaitHint passes, and dwCheckPoint has not been incremented or dwCurrentState has not changed, the server can assume that an error has occurred and the service can be stopped. However, if the service shares a process with other services, the server cannot terminate the service application because it would have to terminate the other services sharing the process as well.