@@ -34,17 +34,20 @@ interface
34
34
35
35
uses
36
36
SysUtils,
37
+ { $IFDEF MSWINDOWS}
37
38
Windows,
38
- { $IFNDEF FPC}
39
39
Messages,
40
40
WinSvc,
41
+ { $ENDIF}
42
+ { $IFNDEF FPC}
41
43
System.IOUtils,
42
44
{ $ELSE}
43
45
Quick.Files,
44
46
{ $ENDIF}
45
47
Quick.Commons,
46
48
Quick.Process;
47
49
50
+ { $IFDEF MSWINDOWS}
48
51
type
49
52
TServiceState = (ssUnknow = -1 ,
50
53
ssStopped = SERVICE_STOPPED,
@@ -54,17 +57,63 @@ interface
54
57
ssContinuePending = SERVICE_CONTINUE_PENDING,
55
58
ssPausePending = SERVICE_PAUSE_PENDING,
56
59
ssPaused = SERVICE_PAUSED);
60
+ { $ENDIF}
57
61
58
- function ServiceIsPresent (const aMachine, aServiceName : string): Boolean;
62
+ { $IFDEF MSWINDOWS}
63
+ function ServiceIsPresent (const aServiceName : string): Boolean; overload;
64
+ function ServiceIsPresent (const aMachine, aServiceName : string): Boolean; overload;
59
65
function GetServicePath : string;
60
66
function GetServiceState (const aServer, aServiceName : string) : TServiceState;
61
- function ServiceStart (const aMachine, aServiceName : string) : Boolean;
62
- function ServiceStop (const aMachine, aServiceName : string ) : Boolean;
67
+ function ServiceStart (const aServiceName : string) : Boolean; overload;
68
+ function ServiceStop (const aServiceName : string ) : Boolean; overload;
69
+ function ServiceStart (const aMachine, aServiceName : string) : Boolean; overload;
70
+ function ServiceStop (const aMachine, aServiceName : string ) : Boolean; overload;
71
+ { $ELSE}
72
+ function ServiceIsPresent (const aServiceName : string): Boolean;
73
+ function ServiceStart (const aServiceName : string) : Boolean;
74
+ function ServiceStop (const aServiceName : string ) : Boolean;
75
+ { $ENDIF}
63
76
function ServiceUninstall (const aServiceName : string): Boolean;
77
+ { $IFDEF MSWINDOWS}
64
78
function DeleteServiceEx (svcName : string) : Boolean;
79
+ { $ENDIF}
65
80
66
81
implementation
67
82
83
+ function ServiceIsPresent (const aServiceName : string) : Boolean;
84
+ { $IFDEF MSWINDOWS}
85
+ begin
86
+ Result := ServiceIsPresent(' localhost' ,aServiceName);
87
+ end ;
88
+ { $ELSE}
89
+ begin
90
+
91
+ end ;
92
+ { $ENDIF}
93
+
94
+ function ServiceStart (const aServiceName : string) : Boolean;
95
+ { $IFDEF MSWINDOWS}
96
+ begin
97
+ Result := ServiceStart(' localhost' ,aServiceName);
98
+ end ;
99
+ { $ELSE}
100
+ begin
101
+
102
+ end ;
103
+ { $ENDIF}
104
+
105
+ function ServiceStop (const aServiceName : string) : Boolean;
106
+ { $IFDEF MSWINDOWS}
107
+ begin
108
+ Result := ServiceStop(' localhost' ,aServiceName);
109
+ end ;
110
+ { $ELSE}
111
+ begin
112
+
113
+ end ;
114
+ { $ENDIF}
115
+
116
+ { $IFDEF MSWINDOWS}
68
117
function ServiceIsPresent (const aMachine, aServiceName : string): Boolean;
69
118
var
70
119
smanHnd : SC_Handle;
@@ -202,8 +251,10 @@ function ServiceStop(const aMachine, aServiceName : string ) : Boolean;
202
251
end ;
203
252
Result := SERVICE_STOPPED = svcStatus.dwCurrentState;
204
253
end ;
254
+ { $ENDIF}
205
255
206
256
function ServiceUninstall (const aServiceName : string): Boolean;
257
+ { $IFDEF MSWINDOWS}
207
258
var
208
259
smanHnd : SC_Handle;
209
260
svchnd : SC_Handle;
@@ -236,7 +287,13 @@ function ServiceUninstall(const aServiceName : string): Boolean;
236
287
end ;
237
288
end ;
238
289
end ;
290
+ { $ELSE}
291
+ begin
292
+
293
+ end ;
294
+ { $ENDIF}
239
295
296
+ { $IFDEF MSWINDOWS}
240
297
function DeleteServiceEx (svcName : string) : Boolean;
241
298
begin
242
299
Result := False;
@@ -245,5 +302,6 @@ function DeleteServiceEx(svcName : string) : Boolean;
245
302
Result := ShellExecuteAndWait(' open' ,' sc' ,' delete ' +svcName,' ' ,0 ,True) = 0 ;
246
303
end ;
247
304
end ;
305
+ { $ENDIF}
248
306
249
307
end .
0 commit comments