function IsWin9x: Boolean;<br>var<br> OsInfo: TOSVERSIONINFO;<br>begin<br> OsInfo.dwOSVersionInfoSize := sizeof(TOSVERSIONINFO);<br> GetVersionEx(OsInfo);<br> Result := (OsInfo.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS);<br>end;<br><br>function SetShutdownPrivilege(Enable: Boolean): Boolean;<br>var<br> PrevPrivileges: TTokenPrivileges;<br> Privileges: TTokenPrivileges;<br> Token: THandle;<br> dwRetLen: DWord;<br>begin<br> Result := False;<br> OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, Token);<br> Privileges.PrivilegeCount := 1;<br> if LookupPrivilegeValue(nil, 'SeShutdownPrivilege', Privileges.Privileges[0].LUID) then<br> begin<br> if Enable then<br> Privileges.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED<br> else<br> Privileges.Privileges[0].Attributes := 0;<br> dwRetLen := 0;<br> Result := AdjustTokenPrivileges(Token, False, Privileges, SizeOf(PrevPrivileges), PrevPrivileges, dwRetLen);<br> end;<br> CloseHandle(Token);<br>end;<br><br>procedure Reboot;<br>begin<br> Application.Terminate;<br> if IsWin9x then<br> ExitWindowsEx(EWX_FORCE or EWX_REBOOT, 0)<br> else<br> begin<br> SetShutdownPrivilege(True);<br> ExitWindowsEx(EWX_FORCE or EWX_REBOOT, 0);<br> SetShutdownPrivilege(False);<br> end;<br>end;<br><br>procedure ShutDown;<br>begin<br> Application.Terminate;<br> if IsWin9x then<br> ExitWindowsEx(EWX_FORCE or EWX_SHUTDOWN, 0)<br> else<br> begin<br> SetShutdownPrivilege(True);<br> ExitWindowsEx(EWX_FORCE or EWX_SHUTDOWN, 0);<br> SetShutdownPrivilege(False);<br> end;<br>end;<br><br><br>-----<br>http://www.8421.org