2005-07-20 17:55:40 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
class WindowsService
|
|
|
|
{
|
|
|
|
protected:
|
2005-08-05 15:02:06 +02:00
|
|
|
bool inited;
|
2005-07-20 17:55:40 +02:00
|
|
|
const char *serviceName;
|
|
|
|
const char *displayName;
|
|
|
|
const char *username;
|
|
|
|
const char *password;
|
|
|
|
SERVICE_STATUS_HANDLE statusHandle;
|
|
|
|
DWORD statusCheckpoint;
|
|
|
|
SERVICE_STATUS status;
|
|
|
|
DWORD dwAcceptedControls;
|
|
|
|
bool debugging;
|
|
|
|
|
|
|
|
public:
|
2005-08-03 23:20:27 +02:00
|
|
|
WindowsService(void);
|
|
|
|
~WindowsService(void);
|
2005-07-20 17:55:40 +02:00
|
|
|
|
2005-08-03 23:20:27 +02:00
|
|
|
BOOL Install();
|
|
|
|
BOOL Remove();
|
|
|
|
BOOL Init();
|
2005-07-20 17:55:40 +02:00
|
|
|
BOOL IsInstalled();
|
|
|
|
void SetAcceptedControls(DWORD acceptedControls);
|
2005-08-05 15:02:06 +02:00
|
|
|
void Debug(bool debugFlag) { debugging= debugFlag; }
|
2005-07-20 17:55:40 +02:00
|
|
|
|
|
|
|
public:
|
2005-08-05 15:02:06 +02:00
|
|
|
static void WINAPI ServiceMain(DWORD argc, LPTSTR *argv);
|
|
|
|
static void WINAPI ControlHandler(DWORD CtrlType);
|
2005-07-20 17:55:40 +02:00
|
|
|
|
|
|
|
protected:
|
2005-08-03 23:20:27 +02:00
|
|
|
virtual void Run()= 0;
|
2005-07-20 17:55:40 +02:00
|
|
|
virtual void Stop() {}
|
|
|
|
virtual void Shutdown() {}
|
|
|
|
virtual void Pause() {}
|
|
|
|
virtual void Continue() {}
|
|
|
|
virtual void Log(const char *msg) {}
|
|
|
|
|
2005-08-03 23:20:27 +02:00
|
|
|
BOOL ReportStatus(DWORD currentStatus, DWORD waitHint= 3000, DWORD dwError=0);
|
2005-07-20 17:55:40 +02:00
|
|
|
void HandleControlCode(DWORD opcode);
|
|
|
|
void RegisterAndRun(DWORD argc, LPTSTR *argv);
|
|
|
|
};
|