58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
#ifndef _WATCHDOG_SERVICE_HPP_
|
|
#define _WATCHDOG_SERVICE_HPP_
|
|
#ifndef _COMMON_WINDOWS_HPP_
|
|
#include <common/windows.hpp>
|
|
#endif
|
|
#ifndef _COMMON_STRING_HPP_
|
|
#include <common/string.hpp>
|
|
#endif
|
|
#ifndef _COMMON_WINSVC_HPP_
|
|
#include <common/winsvc.hpp>
|
|
#endif
|
|
#ifndef _THREAD_EVENT_HPP_
|
|
#include <thread/event.hpp>
|
|
#endif
|
|
#ifndef _WATCHDOG_CREATESERVICEPARAMS_HPP_
|
|
#include <watchdog/CreateServiceParams.hpp>
|
|
#endif
|
|
#ifndef _WATCHDOG_SERVICEHANDLE_HPP_
|
|
#include <watchdog/ServiceHandle.hpp>
|
|
#endif
|
|
#ifndef _WATCHDOG_SERVICECONTROLMANAGER_HPP_
|
|
#include <watchdog/ServiceControlManager.hpp>
|
|
#endif
|
|
#ifndef _WATCHDOG_CBTHUNKSVCMAIN_HPP_
|
|
#include <watchdog/CBThunkSvcMain.hpp>
|
|
#endif
|
|
#ifndef _WATCHDOG_CBTHUNKCTRLHANDLER_HPP_
|
|
#include <watchdog/CBThunkCtrlHandler.hpp>
|
|
#endif
|
|
|
|
class Service : private CBThunkSvcMain, private CBThunkCtrlHandler
|
|
{
|
|
public:
|
|
Service();
|
|
virtual ~Service();
|
|
bool startServiceControlDispatcher(const String &serviceName);
|
|
protected:
|
|
virtual bool initialize(void);
|
|
virtual void controlStop(void);
|
|
virtual void controlPause(void);
|
|
virtual void controlContinue(void);
|
|
virtual void controlInterrogate(void);
|
|
virtual void controlShutdown(void);
|
|
private:
|
|
enum ServiceStatus{Stopped=SERVICE_STOPPED,StartPending=SERVICE_START_PENDING,
|
|
StopPending=SERVICE_STOP_PENDING,Running=SERVICE_RUNNING,ContinuePending=SERVICE_CONTINUE_PENDING,
|
|
PausePending=SERVICE_PAUSE_PENDING,Paused=SERVICE_PAUSED};
|
|
void setStatus(ServiceStatus status,DWORD exitCode=0,DWORD checkPoint=0,DWORD waitHint=0);
|
|
void serviceMain(DWORD dwArgc,LPTSTR *pszArg);
|
|
void controlHandler(DWORD control);
|
|
|
|
String mServiceName;
|
|
SERVICE_STATUS_HANDLE mhServiceStatus;
|
|
Event mServiceEvent;
|
|
ServiceStatus mServiceStatus;
|
|
};
|
|
#endif
|