用api如果实现程序10秒后关闭!(50分)

  • 主题发起人 主题发起人 lovenuo
  • 开始时间 开始时间
L

lovenuo

Unregistered / Unconfirmed
GUEST, unregistred user!
用api如果实现程序10秒后关闭!,不用VCL!
 
unit Unit1;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, StdCtrls;<br><br>type<br> &nbsp;TForm1 = class(TForm)<br> &nbsp; &nbsp;Button1: TButton;<br> &nbsp; &nbsp;procedure FormCreate(Sender: TObject);<br> &nbsp; &nbsp;procedure Button1Click(Sender: TObject);<br> &nbsp;private<br> &nbsp; &nbsp;{ Private declarations }<br> &nbsp;public<br> &nbsp; &nbsp;{ Public declarations }<br> &nbsp;end;<br><br>var<br> &nbsp;Form1: TForm1;<br> &nbsp;FirstTime: Cardinal;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> &nbsp;FirstTime := GetTickCount div 1000;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> &nbsp;while ((GetTickCount div 1000) - (FirstTime) &lt; 10) do Application.ProcessMessages;<br> &nbsp;Close;<br>end;<br><br>end.
 
用个时钟就OK了
 
ExitWindowsEx(EWX_SHUTDOWN and EWX_POWEROFF ,1);
 
接受答案了.
 
Application.ProcessMessages<br>我写和程序没有实体窗口,上面的不能用,还有别的语句代替吗!
 
后退
顶部