unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs,<br> ExtCtrls, WinSvc;<br><br>type<br> TServerServiceName = class(TService)<br> Timer1: TTimer;<br> procedure Timer1Timer(Sender: TObject);<br> private<br> LogStr:String;<br> { Private declarations }<br> public<br> function GetServiceController: TServiceController; override;<br> { Public declarations }<br> end;<br><br>var<br> ServerServiceName: TServerServiceName;<br> WndCaption: String;<br> FoundWnd: integer;<br>implementation<br>Uses PublibUnit;<br>{$R *.DFM}<br><br>procedure ServiceController(CtrlCode: DWord); stdcall;<br>begin<br> ServerServiceName.Controller(CtrlCode);<br>end;<br><br>function TServerServiceName.GetServiceController: TServiceController;<br>begin<br> Result := ServiceController;<br>end;<br><br>function EnumWndProc(hwnd: Thandle; Param: Cardinal): Bool; stdcall;<br>var<br> WndTitleText, WinModuleName: string;<br> WinInstance: THandle;<br>begin<br> Result := True;<br> SetLength(WndTitleText,100);<br> GetWindowText(hwnd,pchar(WndTitleText),Length(WndTitleText));<br> WndTitleText := Pchar(WndTitleText);<br> if pos(WndCaption,WndTitleText)&gt;0 then<br> begin<br> FoundWnd := Hwnd;<br> Result := False; <br> end<br> else<br> FoundWnd:=0;<br>end;<br><br>procedure TServerServiceName.Timer1Timer(Sender: TObject);<br>var<br> ModuleName: string;<br>begin<br>Try<br> FoundWnd := 0;<br> WndCaption := 'ACCESSPassword';<br> EnumWindows(@EnumWndProc,0);<br> if FoundWnd=0 then<br> WinExec('E:/Access/Project1.exe',0);<br>Except on E : Exception do<br> Begin<br> LogStr := E.Message;<br> PublibUnit.Write_log(LogStr);<br> //Showmessage(E.Message);<br> End;<br>End;<br>end;<br><br>end.