-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServiceManager.h
56 lines (49 loc) · 1.5 KB
/
ServiceManager.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
50
51
52
53
54
55
56
#pragma once
#include <afxtempl.h>
#include <WinSvc.h>
enum Status
{
Unknown = 0,
Active = 1,
Inactive = 2
};
struct Service
{
public: //interface
inline Service() : pid(0), status(Unknown) {}
inline ~Service() {}
inline Service(Service& service) { *this = service; }
Service& operator=(Service& service);
inline CString GetName() { return name; }
inline CString GetDisplayName() { return display_name; }
inline int GetProcessID() { return pid; }
inline Status GetStatus() { return status; }
protected: //data
CString name;
CString display_name;
int pid;
Status status;
friend class ServiceManager;
};
#define CServiceArray CArray<Service,Service>
class ServiceManager
{
public: //interface
inline ServiceManager(void) : manager(0) {}
inline ~ServiceManager(void) { CleanUp(); }
bool Initialize();
void CleanUp();
CString GetExePath(const TCHAR* name);
bool GetServices(CServiceArray& services, int status_mask = Active|Inactive);
bool StartService(const TCHAR* name);
bool StopService(const TCHAR* name);
//void __stdcall DoStartSvc(const TCHAR* name);
// Incase of Error with StartService Uncomment the Above line and also the DoStartSvc function from ServiceManager.cpp
//void __stdcall DoStopSvc(const TCHAR* name);
//BOOL __stdcall StopDependentServices(SC_HANDLE schService);
// Incase of Error with StopService Uncomment the Above line and also the DoStopSvc function from ServiceManager.cpp
//int EnumerateAllServices();
protected: //data
SC_HANDLE manager;
friend struct Service;
};