procedure TForm1.xq_close(cr:integer); //关闭电脑
var
 //       st : SYSTEMTIME;
        hToken : THANDLE;
        tkp : TOKEN_PRIVILEGES;
        rr : Dword;
begin
        OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,hToken);
        LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid);
       
        tkp.PrivilegeCount := 1;
        tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
       
        AdjustTokenPrivileges(hToken, FALSE, tkp, 0,nil,rr);
       
        if cr=0 then
          ExitWindowsEx(EWX_SHUTDOWN+EWX_FORCE,0)
          
        else
     
        ExitWindowsEx(EWX_REBOOT,2);
       //ExitWindowsEx(EWX_REBOOT OR EWX_POWEROFF, 0)
end;