to:Baylon5,你对我的第二个问题的答复是对的,设成stAuto的确可以不写用户名和密码;
to:一生中最爱,
你说的Execute是什么意思?是不是要附加一个线程?
我现在做的这个试验,是在Tservice的框中放了一个timer,ontimer里面发了一个showmessage
要定时发出一个对话框就行了,结果执行几次自动就关掉了;
************************************我的代码如下******************************
unit srvtest;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs,
ExtCtrls;
type
TTest = class(TService)
Timer1: TTimer;
procedure ServiceContinue(Sender: TService; var Continued: Boolean);
procedure ServicePause(Sender: TService; var Paused: Boolean);
procedure ServiceStart(Sender: TService; var Started: Boolean);
procedure ServiceStop(Sender: TService; var Stopped: Boolean);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
function GetServiceController: TServiceController; override;
{ Public declarations }
end;
var
Test: TTest;
implementation
{$R *.DFM}
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
Test.Controller(CtrlCode);
end;
function TTest.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
procedure TTest.ServiceContinue(Sender: TService; var Continued: Boolean);
begin
continued:=true;
end;
procedure TTest.ServicePause(Sender: TService; var Paused: Boolean);
begin
paused:=true;
end;
procedure TTest.ServiceStart(Sender: TService; var Started: Boolean);
begin
started:=true;
end;
procedure TTest.ServiceStop(Sender: TService; var Stopped: Boolean);
begin
stopped:=true;
end;
procedure TTest.Timer1Timer(Sender: TObject);
begin
showmessage('OK');
end;
end.