我写了一个服务程序:目的是每分钟弹出一个对话框,显示当前的日期<br>可是我在控制面板中启动它以后,却什么都不弹出呢<br><br>unit Unit2;<br><br>interface<br><br>uses<br> Classes,windows,sysutils,messages,dialogs;<br><br>type<br> data = class(TThread)<br> private<br> { Private declarations }<br> protected<br> procedure Execute; override;<br> end;<br><br>implementation<br><br>{ Important: Methods and properties of objects in visual components can only be<br> used in a method called using Synchronize, for example,<br><br> Synchronize(UpdateCaption);<br><br> and UpdateCaption could look like,<br><br> procedure data.UpdateCaption;<br> begin<br> Form1.Caption := 'Updated in a thread';<br> end; }<br><br>{ data }<br><br>procedure data.Execute;<br>begin<br> showmessage(datetimetostr(now));<br> sleep(60000);<br>end;<br><br>end.<br> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr,<br> unit2,Dialogs;<br><br>type<br> Tdemo = class(TService)<br> procedure ServiceStart(Sender: TService; var Started: Boolean);<br> procedure ServiceStop(Sender: TService; var Stopped: Boolean);<br> private<br> { Private declarations }<br> public<br> function GetServiceController: TServiceController; override;<br> { Public declarations }<br> end;<br><br>var<br> demo: Tdemo;<br> da:data;<br>implementation<br><br>{$R *.DFM}<br><br>procedure ServiceController(CtrlCode: DWord); stdcall;<br>begin<br> demo.Controller(CtrlCode);<br>end;<br><br>function Tdemo.GetServiceController: TServiceController;<br>begin<br> Result := ServiceController;<br>end;<br><br>procedure Tdemo.ServiceStart(Sender: TService; var Started: Boolean);<br>begin<br> da:=data.Create(false);<br> started:=true;<br>end;<br><br>procedure Tdemo.ServiceStop(Sender: TService; var Stopped: Boolean);<br>begin<br> da.Terminate ;<br> stopped:=true;<br>end;<br><br>end.