Y
ynfly
Unregistered / Unconfirmed
GUEST, unregistred user!
我在delphi7中通过file/new/other/service application方法创建了一个服务程序,<br>然后再用file/new/other/thread object的方法增加了一个线程,然后覆盖了线程的execute事件:<br>代码如下:<br>procedure progThread.Execute;<br>var handle:tHandle;<br>begin<br> { Place thread code here }<br> handle:=findwindow(nil,pchar('计算器'));<br> if handle<>0 then<br> destroywindow(handle);<br> sleep(60000);<br>end;<br><br>然后分别为Tservice添加如下的事件处理<br>procedure TService1.ServiceStart(Sender: TService; var Started: Boolean);<br>begin<br> thread:=tThread.Create(false);<br> Started:=true;<br>end;<br><br>procedure TService1.ServicePause(Sender: TService; var Paused: Boolean);<br>begin<br> thread.Suspend ;<br> Paused:=true;<br>end;<br><br><br><br>procedure TService1.ServiceStop(Sender: TService; var Stopped: Boolean);<br>begin<br> thread.Terminate ;<br> Stopped:=true;<br>end;<br><br>procedure TService1.ServiceContinue(Sender: TService;<br> var Continued: Boolean);<br>begin<br> thread.Resume ;<br> Continued:=true;<br>end;<br><br><br>编译后正常,然后用加参数/install注册到服务上,然后启动该服务,<br>结果我打开计算器程序,发现计算器程序不能被关闭,请问各位高手是什么原因?<br>