试试下面这个吧,绝对没问题!<br>procedure ShutDown(bShut:Boolean);<br>const<br> SE_SHUTDOWN_NAME = 'SeShutdownPrivilege'; <br>var<br> hToken : THandle;<br> tkp : TTokenPrivileges;<br> tkpo : TTokenPrivileges;<br>begin<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> 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;