一个记时器TIMER<br>还需要下面的函数<br>下面的函数在98,2000,XP下都有效,你自己试试吧.<br>procedure ShutDown(const tpye: integer);<br>const<br> SE_SHUTDOWN_NAME = 'SeShutdownPrivilege';<br>var<br> hToken: THandle;<br> tkp: TTokenPrivileges;<br> tkpo: TTokenPrivileges;<br> zero: DWORD;<br>function GetVersion: string;<br>var<br> VersionInfo: TOSVersionInfo;<br> OSName: string;<br>begin<br> VersionInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);<br> if Windows.GetVersionEx(VersionInfo) then<br> begin<br> with VersionInfo do<br> begin<br> case dwPlatformId of<br> VER_PLATFORM_WIN32s: OSName := 'Win32s';<br> VER_PLATFORM_WIN32_WINDOWS: OSName := 'Windows 95';<br> VER_PLATFORM_WIN32_NT: OSName := 'Windows NT';<br> end;<br> Result := OSName;<br> end;<br> end<br> else<br> Result := '';<br>end;<br>begin<br> if Pos('Windows NT', GetVersion) = 1 then<br> begin<br> zero := 0;<br> if not OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then<br> begin<br> MessageBox(0, 'Exit Error', 'OpenProcessToken() Failed', MB_OK);<br> Exit;<br> end;<br> if not OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then<br> begin<br> MessageBox(0, 'Exit Error', 'OpenProcessToken() Failed', MB_OK);<br> Exit;<br> end;<br> if not LookupPrivilegeValue(nil, 'SeShutdownPrivilege', tkp.Privileges[0].Luid) then<br> begin<br> MessageBox(0, 'Exit Error', 'LookupPrivilegeValue() Failed', MB_OK);<br> Exit;<br> end;<br> tkp.PrivilegeCount := 1;<br> tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;<br> AdjustTokenPrivileges(hToken, False, tkp, SizeOf(TTokenPrivileges), tkpo, zero);<br> if Boolean(GetLastError()) then<br> begin<br> MessageBox(0, 'Exit Error', 'AdjustTokenPrivileges() Failed', MB_OK);<br> Exit;<br> end;<br> end;<br> ExitWindowsEx(tpye, 0);<br>end;<br>//tpye定义如下<br>{<br><br> EWX_LOGOFF = 0;<br><br> EWX_SHUTDOWN = 1;<br><br> EWX_REBOOT = 2;<br><br> EWX_FORCE = 4;<br><br> EWX_POWEROFF = 8;<br><br> EWX_FORCEIFHUNG = $10;<br>}