Window重启程序,要完整的(在线等) ( 积分: 50 )

  • 主题发起人 主题发起人 bazooko
  • 开始时间 开始时间
B

bazooko

Unregistered / Unconfirmed
GUEST, unregistred user!
Window重启程序,要完整的(在线等)
 
Window重启程序,要完整的(在线等)
 
 软件装完之后有的要提示系统重启,我要的就是那种效果,,
 
unit Unit1;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, StdCtrls, DB, DBTables, ExtCtrls;<br><br>type<br> &nbsp;TForm1 = class(TForm)<br> &nbsp; &nbsp;Button1: TButton;<br> &nbsp; &nbsp;Button2: TButton;<br> &nbsp; &nbsp;Query: TQuery;<br> &nbsp; &nbsp;Edit1: TEdit;<br> &nbsp; &nbsp;Button3: TButton;<br> &nbsp; &nbsp;Timer1: TTimer;<br> &nbsp; &nbsp;Edit2: TEdit;<br> &nbsp; &nbsp;Edit3: TEdit;<br> &nbsp; &nbsp;Edit4: TEdit;<br> &nbsp; &nbsp;Edit5: TEdit;<br> &nbsp; &nbsp;Edit6: TEdit;<br> &nbsp; &nbsp;procedure Button1Click(Sender: TObject);<br> &nbsp; &nbsp;procedure Button2Click(Sender: TObject);<br> &nbsp; &nbsp;procedure Button3Click(Sender: TObject);<br> &nbsp; &nbsp;procedure Timer1Timer(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><br><br>implementation<br>function ShutDown(uFlags: Cardinal):boolean;<br>const<br> &nbsp;ADJUST_PRIV = TOKEN_QUERY or TOKEN_ADJUST_PRIVILEGES;<br> &nbsp;SHTDWN_PRIV = 'SeShutdownPrivilege';<br> &nbsp;PRIV_SIZE &nbsp; = sizeOf(TTokenPrivileges);<br>var<br> &nbsp;Len: DWORD;<br> &nbsp;TokenPriv, Dummy: TTokenPrivileges;<br> &nbsp;Token: THandle;<br> &nbsp;Error:integer;<br>begin<br> &nbsp;error:=0;<br> &nbsp;// 设置特权<br> &nbsp;// Delphi2:<br> &nbsp;//if not OpenProcessToken(GetCurrentProcess(), ADJUST_PRIV, @Token) then<br> &nbsp;if not OpenProcessToken(GetCurrentProcess(), ADJUST_PRIV, Token) then<br> &nbsp; &nbsp; &nbsp;Error := Error or 4;<br> &nbsp;if not LookupPrivilegeValue(nil, SHTDWN_PRIV,TokenPriv.Privileges[0].Luid) then<br> &nbsp; &nbsp;Error := Error or 8;<br> &nbsp;TokenPriv.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;<br> &nbsp;TokenPriv.PrivilegeCount := 1; &nbsp;// One privilege to set<br> &nbsp;if not AdjustTokenPrivileges(Token, false, TokenPriv, PRIV_SIZE,Dummy, Len) then<br> &nbsp; &nbsp;Error:=Error or 16;<br> &nbsp;ExitWindowsEx(uFlags, 0);<br> &nbsp;Result := (Error=0);<br>end;<br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>if(formatdatetime('hh',now)=edit1.Text)then<br>ShutDown(EWX_POWEROFF + EWX_FORCE);<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>Showmessage(datetimetostr(now));<br>showmessage(formatdatetime('hh',now));<br>end;<br><br>procedure TForm1.Button3Click(Sender: TObject);<br>begin<br> ShutDown(EWX_POWEROFF + EWX_FORCE);<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>begin<br>button1.Click;<br>end;<br><br>end.<br>
 
后退
顶部