FreeRDP-WebConnect WebSockets gateway
1.0.0.167
|
A class for implementing a Windows service. More...
#include <NTService.hpp>
Public Types | |
enum | { SERVICE_CONTROL_USER = 128 } |
Public Member Functions | |
NTService (const std::string &displayName, const std::string &serviceName="") | |
Constructor. | |
bool | IsServiceInstalled () const |
Retrieve installation status. | |
void | Start () const |
Starts the service. | |
void | Stop () const |
Stops the service. | |
void | InstallService () const |
Installs the service. | |
void | UninstallService () const |
Uninstalls the service. | |
bool | Execute () const |
Attempts to start the service control dispatcher. | |
uint32_t | ServiceExitCode () const |
Retrieves the exit code of the service. |
Protected Member Functions | |
virtual bool | OnServiceInit (uint32_t argc, char **argv) |
Perform initialization using the service arguments. | |
virtual void | RunService () |
Runs the service main loop. | |
virtual bool | OnServiceStop () |
Notifies the service to be stopped. | |
virtual bool | OnServiceInterrogate () |
Notifies the service to be queried. | |
virtual bool | OnServicePause () |
Notifies the service to be paused. | |
virtual bool | OnServiceContinue () |
Notifies the service to resume. | |
virtual bool | OnServiceShutdown () |
Notifies the service about a system shutdown. | |
virtual bool | OnServiceParamChange () |
Notifies the service about a parameter change. | |
virtual bool | OnServiceDeviceEvent () |
Notifies the service about a device event. | |
virtual bool | OnServiceHardwareProfileChange () |
Notifies the service about a changed hardware profile. | |
virtual bool | OnServicePowerEvent () |
Notifies the service about a power management event. | |
virtual bool | OnServiceSessionChange () |
Notifies the service about a session change. | |
virtual bool | OnServiceUserControl (uint32_t opcode) |
Notifies the service about a user-defined control message. | |
std::string | StatusString (uint32_t state) |
Converts a service state to a human readable string. | |
std::string | CtrlString (uint32_t ctrl) |
Converts a control code to a human readable string. | |
void | AddDependency (const std::string &s) |
Adds a dependency to the list of prerequisites for this service. | |
void | SetServiceStatus (uint32_t state) |
Changes and reports the service status to the service control manager. | |
void | ReportServiceStatus () |
Reports the current service status to the service control manager. |
Protected Attributes | |
bool | m_bServiceRunning |
Flag: service is running. | |
uint32_t | m_dwServiceStartupType |
The startup type of this service. | |
SERVICE_STATUS | m_ServiceStatus |
The startupt type of this service. | |
std::string | m_sServiceName |
The internal service name. | |
std::string | m_sDisplayName |
The display name. | |
std::string | m_sDescription |
An optional description. | |
std::string | m_sModulePath |
Internal path to our executable. |
A class for implementing a Windows service.
Internally, this class is a singleton, so you can only have one instance in a program. In convert a program into a service, its main() function should be renamed an then being invoked from your derived class Execute() method.
Definition at line 37 of file NTService.hpp.
wsgate::NTService::NTService | ( | const std::string & | displayName, |
const std::string & | serviceName = "" |
||
) |
Constructor.
displayName | Mandatory display name of the service |
serviceName | Optional internal service name |
|
protected |
Adds a dependency to the list of prerequisites for this service.
s | The name of another service on which this service depends. |
|
protected |
Converts a control code to a human readable string.
ctrl | The control code to convert. |
bool wsgate::NTService::Execute | ( | ) | const |
Attempts to start the service control dispatcher.
An | instance of tracing::runtime_error, if the service manager can not be contacted. |
void wsgate::NTService::InstallService | ( | ) | const |
Installs the service.
An | instance of tracing::runtime_error, if the service manager can not be contacted or the service can not be installed. |
bool wsgate::NTService::IsServiceInstalled | ( | ) | const |
Retrieve installation status.
An | instance of tracing::runtime_error, if the service manager can not be contacted. |
|
protectedvirtual |
Notifies the service to resume.
To be overridden by your derived class. The default implementation just returns true.
|
protectedvirtual |
Notifies the service about a device event.
To be overridden by your derived class. The default implementation just returns true.
|
protectedvirtual |
Notifies the service about a changed hardware profile.
To be overridden by your derived class. The default implementation just returns true.
|
protectedvirtual |
Perform initialization using the service arguments.
To be overridden by your derived class. The default implementation just returns true.
argc | The number of arguments. |
argv | A NULL terminated array of string pointers. |
|
protectedvirtual |
Notifies the service to be queried.
To be overridden by your derived class. The default implementation just returns true.
|
protectedvirtual |
Notifies the service about a parameter change.
To be overridden by your derived class. The default implementation just returns true.
|
protectedvirtual |
Notifies the service to be paused.
To be overridden by your derived class. The default implementation just returns true.
|
protectedvirtual |
Notifies the service about a power management event.
To be overridden by your derived class. The default implementation just returns true.
|
protectedvirtual |
Notifies the service about a session change.
To be overridden by your derived class. The default implementation just returns true.
|
protectedvirtual |
Notifies the service about a system shutdown.
To be overridden by your derived class. The default implementation just returns true.
|
protectedvirtual |
Notifies the service to be stopped.
To be overridden by your derived class. The default implementation just returns true.
|
protectedvirtual |
Notifies the service about a user-defined control message.
To be overridden by your derived class. The default implementation just returns true.
opcode | The user defined control code. |
|
protectedvirtual |
Runs the service main loop.
To be overridden by your derived class. The default implementation just loops until the service is stopped.
uint32_t wsgate::NTService::ServiceExitCode | ( | ) | const |
Retrieves the exit code of the service.
|
protected |
Changes and reports the service status to the service control manager.
state | The new state of this service. |
void wsgate::NTService::Start | ( | ) | const |
Starts the service.
An | instance of tracing::runtime_error, if the service manager can not be contacted or the service can not be started. |
|
protected |
Converts a service state to a human readable string.
state | The state to convert. |
void wsgate::NTService::Stop | ( | ) | const |
Stops the service.
An | instance of tracing::runtime_error, if the service manager can not be contacted or the service can not be stopped. |
void wsgate::NTService::UninstallService | ( | ) | const |
Uninstalls the service.
An | instance of tracing::runtime_error, if the service manager can not be contacted or the service can not be uninstalled. |