//操作函數:注銷.重起.關機<br>procedure operatecomputer(statue:longword);<br>var<br>hToken:THandle;<br>tkp : TOKEN_PRIVILEGES;<br>ReturnLength : DWord;<br>begin<br>if (not OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES or TOKEN_ALL_ACCESS or TOKEN_QUERY, hToken))then<br>begin<br>application.Terminate;<br>end;<br>LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid);<br>tkp.PrivilegeCount := 1;<br>tkp.Privileges[0].Attributes :=SE_PRIVILEGE_ENABLED;<br>ReturnLength :=0;<br>AdjustTokenPrivileges(hToken, FALSE, tkp, 0,nil,ReturnLength);<br>if (GetLastError() <> ERROR_SUCCESS) then<br>begin<br>application.Terminate;<br>end;<br>if (not ExitWindowsEx(statue, 0)) then<br>begin<br>application.Terminate;<br>end;<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>var<br>s:string;<br>NTime,MTime,OnTime,OnTime1,Onreboot : String;<br>begin<br> s:=label12.Caption;<br> label12.Caption:=timetostr(StrToTime(S));<br> label10.Caption:=datetostr(date);<br> label12.Caption:=timetostr(time);<br> OnTime:=TimeToStr(DateTimePicker5.Time);<br> OnTime1:=TimeToStr(DateTimePicker6.Time);<br> NTime:=TimeToStr(DateTimePicker3.Time);<br> MTime:=TimeToStr(DateTimePicker4.Time);<br> Onreboot:=TimeToStr(DateTimePicker7.Time);<br> if (DateTimePicker5.Checked=true) and (DateTimePicker5.Enabled=true) then<br> if ontime=S then<br> begin<br> showmessage('你設定的時間已經到了!');<br> end;<br> if (DateTimePicker6.Checked=true) and (DateTimePicker6.Enabled=true) then<br> if ontime1=S then<br> begin<br> showmessage('時間過的好快啊,又到了!');<br> end;<br><br> if NTime=s then<br> begin<br> if win32platform =ver_platform_win32_windows then<br> exitwindowsex(ewx_force+ewx_shutdown+ewx_poweroff,32);<br> if win32platform =ver_platform_win32_NT then<br> operatecomputer(ewx_reboot); //ewx_reboot 重起&#63236;<br> end;<br> if (MTime=s) and (DateTimePicker4.Enabled=true) then<br> begin<br> if win32platform =ver_platform_win32_windows then<br> exitwindowsex(ewx_force+ewx_shutdown+ewx_poweroff,32);<br> if win32platform =ver_platform_win32_NT then<br> operatecomputer(ewx_reboot); //ewx_reboot 重起&#63236;<br> end;<br> if (DateTimePicker7.Checked=true) and (DateTimePicker7.Enabled=true) then<br> if Onreboot=s then<br> begin<br> if win32platform =ver_platform_win32_windows then<br> exitwindowsex(ewx_force+ewx_shutdown+ewx_poweroff,32);<br> if win32platform =ver_platform_win32_NT then<br> operatecomputer(ewx_poweroff); //ewx_logoff 關機<br> end;<br><br>end;