可以的,你可以这样做,查询服务的状态,如果存在,就启动他,不存在的话就注册、启动<br>在工程中这样写:<br>var<br> i:Integer;<br><br>{$R *.res}<br><br>begin<br> i:=QueryServiceState('MyService');<br> case i of<br> 0:<br> begin<br> if wInstallService('MyService','ServiceName','服务描述',ParamStr(0)) then<br> wServiceStart('','MyService');<br> end;<br> 1:<br> begin<br> wServiceStart('','MyService');<br> end;<br> end;//case<br> Forms.Application.Initialize;<br> forms.Application.CreateForm(TMainForm, MainForm);<br> forms.Application.CreateForm(TForm1, Form1);<br> svcmgr.Application.Initialize;<br> svcmgr.Application.CreateForm(TMyService, MyService);<br><br> svcmgr.Application.Run;<br> forms.Application.Run;<br>end.<br><br>还有,别忘了加入 一个TService