-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUnit1.pas
62 lines (44 loc) · 1.37 KB
/
Unit1.pas
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
59
60
61
62
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.SvcMgr, Vcl.Dialogs,shellapi,
Vcl.ExtCtrls;
type
TService1 = class(TService)
Timer1: TTimer;
procedure ServiceStart(Sender: TService; var Started: Boolean);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
function GetServiceController: TServiceController; override;
{ Public declarations }
end;
var
Service1: TService1;
implementation
{$R *.dfm}
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
Service1.Controller(CtrlCode);
end;
function TService1.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
procedure TService1.ServiceStart(Sender: TService; var Started: Boolean);
begin
timer1.enabled:=true;
//Ê×´ÎΪ6ÃëÑÓ³Ù
ShellExecute(0, 'open', pwidechar('net'),'stop w32time','', SW_HIDE);
ShellExecute(0, 'open', pwidechar('w32tm'),'/unregister','', SW_HIDE);
ShellExecute(0, 'open', pwidechar('w32tm'),'/register','', SW_HIDE);
ShellExecute(0, 'open', pwidechar('net'),'start w32time','', SW_HIDE);
ShellExecute(0, 'open', pwidechar('w32tm'),'/resync','', SW_HIDE);
end;
procedure TService1.Timer1Timer(Sender: TObject);
begin
timer1.Interval:=600000; //10min
ShellExecute(0, 'open', pwidechar('w32tm'),'/resync','', SW_HIDE);
end;
end.