我这个绝对可以关闭电源 关机前可千万别忘了一件事——给我加分:)<br>procedure ShutDown(bShut:Boolean);<br>const<br> SE_SHUTDOWN_NAME = 'SeShutdownPrivilege'; // Borland forgot this declaration<br>var<br> hToken : THandle;<br> tkp : TTokenPrivileges;<br> tkpo : TTokenPrivileges;<br> zero : DWORD;<br> VersionInfo : TOSVERSIONINFO;<br>begin<br> versioninfo.dwOSVersionInfoSize :=SizeOf( TOSVersionInfo );<br> GetVersionEx(versioninfo);<br> if versioninfo.dwPlatformId=VER_PLATFORM_WIN32_NT then<br> begin<br> zero := 0;<br> if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then<br> MessageBox( 0, 'Error', 'OpenProcessToken() Failed', MB_OK );<br> if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then<br> MessageBox( 0, 'Error', 'OpenProcessToken() Failed', MB_OK );<br> // SE_SHUTDOWN_NAME<br> if not LookupPrivilegeValue( nil, SE_SHUTDOWN_NAME , tkp.Privileges[ 0 ].Luid ) then<br> MessageBox( 0, 'Error', 'LookupPrivilegeValue() Failed', MB_OK );<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> MessageBox( 0, 'Error', 'AdjustTokenPrivileges() Failed', MB_OK )<br> else<br> ExitWindowsEx(EWX_POWEROFF or EWX_FORCE,0)<br> end // if Windows NT<br> else // just shut the machine down<br> ExitWindowsEx(EWX_SHUTDOWN or EWX_FORCE, 0 )<br>end;