-
Notifications
You must be signed in to change notification settings - Fork 573
/
Copy pathWeaselService.h
49 lines (35 loc) · 1.16 KB
/
WeaselService.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include <Windows.h>
#include <memory>
#include "WeaselServerApp.h"
#define WEASEL_SERVICE_NAME L"WeaselInputService"
class WeaselService {
public:
WeaselService(BOOL fCanStop, BOOL fCanShutdown, BOOL fCanPauseContinue);
~WeaselService();
static BOOL Run(WeaselService& serv);
void Stop();
// Start the service.
void Start(DWORD dwArgc, PWSTR* pszArgv);
protected:
// Entry point for the service. It registers the handler function for the
// service and starts the service.
static void WINAPI ServiceMain(DWORD dwArgc, PWSTR* pszArgv);
// The function is called by the SCM whenever a control code is sent to
// the service.
static void WINAPI ServiceCtrlHandler(DWORD dwCtrl);
void SetServiceStatus(DWORD dwCurrentState,
DWORD dwWin32ExitCode = NO_ERROR,
DWORD dwWaitHint = 0);
// Execute when the system is shutting down.
void Shutdown();
private:
static WeaselService* _service;
// The status of the service
SERVICE_STATUS _status;
// The service status handle
SERVICE_STATUS_HANDLE _statusHandle;
BOOL _stopping;
HANDLE _stoppedEvent;
WeaselServerApp app;
};