-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServiceController.h
58 lines (52 loc) · 2.25 KB
/
ServiceController.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
57
58
//---------------------------------------------------------------------------
#ifndef ServiceControllerH
#define ServiceControllerH
//---------------------------------------------------------------------------
#include <stdlib.h>
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
enum ServiceState {None, Stopped, Starting, Stopping, Running, Continuing, Pausing, Paused};
enum StartType {Automatic = SERVICE_AUTO_START, Manual = SERVICE_DEMAND_START, Disabled = SERVICE_DISABLED};
//---------------------------------------------------------------------------
class PACKAGE TServiceController : public TComponent
{
private:
bool ManagerOpen;
bool CanInstall;
SC_HANDLE ManHandle;
SC_HANDLE SvcHandle;
LPSERVICE_STATUS Status;
AnsiString *FServiceName;
ServiceState FStatus;
AnsiString *FStatusString;
void __fastcall ThrowException(int i);
void __fastcall OpenManager(bool InstallAccess);
void __fastcall CloseManager();
ServiceState __fastcall MapState(DWORD i);
protected:
virtual AnsiString __fastcall GetServiceName();
virtual void __fastcall SetServiceName(AnsiString sn);
virtual ServiceState __fastcall GetStatus();
virtual AnsiString __fastcall GetStatusString();
public:
__fastcall TServiceController(TComponent *Owner);
__fastcall ~TServiceController();
void __fastcall OpenServ(AnsiString ServName);
void __fastcall CloseServ();
void __fastcall Install(AnsiString SvcName, AnsiString DispName, StartType st, AnsiString FilePath, bool Interactive);
void __fastcall Uninstall();
void __fastcall Start();
void __fastcall Stop();
void __fastcall Pause();
void __fastcall Continue();
void __fastcall QueryStatus();
__published:
__property AnsiString ServiceName = {read=GetServiceName, nodefault};
__property ServiceState ServiceStatus = {read=GetStatus, nodefault};
__property AnsiString ServiceStatusString = {read=GetStatusString, nodefault};
};
//---------------------------------------------------------------------------
#endif