Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs;
- type
- TService12 = class(TService)
- procedure ServiceStart(Sender: TService; var Started: Boolean);
- procedure ServiceStop(Sender: TService; var Stopped: Boolean);
- procedure ServiceExecute(Sender: TService);
- private
- { Private declarations }
- public
- function GetServiceController: TServiceController; override;
- { Public declarations }
- end;
- type
- TThread1 = class(TThread)
- private
- { Private declarations }
- protected
- procedure Execute; override;
- end;
- var
- Service12: TService12;
- Thread1: TThread1;
- implementation
- {$R *.DFM}
- procedure ServiceController(CtrlCode: DWord); stdcall;
- begin
- Service12.Controller(CtrlCode);
- end;
- function TService12.GetServiceController: TServiceController;
- begin
- Result := ServiceController;
- end;
- procedure write();
- var s:string;
- RC: Cardinal;
- f:textfile;
- begin
- try
- assignfile(f,'temp1.txt');
- rewrite(f);
- writeln(f,'123');
- closefile(f);
- OutputDebugString('ADD');
- except
- OutputDebugString('ERROR');
- end;
- end;
- procedure TThread1.Execute;
- begin
- while (true) do begin
- OutputDebugString('Start');
- write();
- OutputDebugString('END');
- Sleep(15000);
- end;
- end;
- procedure TService12.ServiceStart(Sender: TService; var Started: Boolean);
- begin
- Thread1:=TThread1.Create(False);
- Thread1.Priority:=tpNormal;
- Started := True;
- end;
- procedure TService12.ServiceStop(Sender: TService; var Stopped: Boolean);
- begin
- Stopped := True;
- end;
- procedure TService12.ServiceExecute(Sender: TService);
- begin
- while not Terminated do begin
- ServiceThread.ProcessRequests(False);
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement