xp好像是要得到权限才可以关机重启的。//取得关机权限function TForm1.SetPrivilege(sPrivilegeName: string; bEnabled: Boolean): Boolean;var TPPrev, TP : TTokenPrivileges; Token :THandle; dwRetLen : DWORD;begin result := False; OpenProcessToken (GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, Token); TP.PrivilegeCount := 1; if LookupPrivilegeValue (nil, PChar (sPrivilegeName), TP.Privileges[0].LUID) then begin if bEnabled then TP.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED else TP.Privileges[0].Attributes := 0; dwRetLen := 0; result := AdjustTokenPrivileges ( Token, False, TP, SizeOf (TPPrev), TPPrev, dwRetLen); end; CloseHandle (Token);end;function TForm1.WinExit(iFlags: integer): Boolean;beginresult := true; if SetPrivilege ('SeShutdownPrivilege', true) then begin if (not ExitWindowsEx (iFlags, 0)) then begin result := False end; SetPrivilege ('SeShutdownPrivilege', False) end else begin result := False end;end;重启的话,你可以翻看帮助,改下相应的函数就行了。