{$ifdef Delphi32LessThan3} procedure Win32Check(Value: Boolean); begin if not Value then raise Exception.Create(SysErrorMessage(GetLastError)) end; {$endif}
procedure TForm1.btnRestartClick(Sender: TObject); var HToken: THandle; TP, OldTP: TTokenPrivileges; ReturnLen: Integer; begin if Win32Platform = VER_PLATFORM_WIN32_NT then begin //Get a token for this process Win32Check(OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, {$ifdef Delphi32LessThan3}@{$endif}HToken)); //Get the LUID for the shutdown privilege Win32Check(LookupPrivilegeValue(nil, 'SeShutdownPrivilege', TP.Privileges[0].Luid)); TP.PrivilegeCount := 1; //One privilege to set TP.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED; //Acquire shutdown privilege for this process Win32Check(AdjustTokenPrivileges(HToken, False, TP, SizeOf(OldTP), OldTP, ReturnLen)); end; //Shut down the system and force all applications to close if not ExitWindowsEx(EWX_SHUTDOWN {or EWX_FORCE}, 0) then raise Exception.Create('Cannot shut Windows'); Close; end;
[Error] Shutdown.pas(60): There is no overloaded version of 'AdjustTokenPrivileges' that can be called with these arguments ??? Bruger Delphi 6 Enterprise
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.