Delphi Sources

Как выключить Win2000 2




procedure NTShutdown;
var
  TokenHandle: Cardinal;
  RetLength: Cardinal;
  TP: TTokenPrivileges;
begin
  OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
    or TOKEN_QUERY, TokenHandle);
  if LookupPrivilegeValue(nil, 'SeShutdownPrivilege',
    TP.Privileges[0].Luid) then
  begin
    TP.PrivilegeCount := 1;
    TP.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
    RetLength := 0;
    if AdjustTokenPrivileges(TokenHandle, FALSE, TP, 0, nil, RetLength) then
    begin
      if not SetProcessShutdownParameters($4FF, SHUTDOWN_NORETRY) then
      begin
        MessageBox(0, 'Shutdown failed', nil, MB_OK or MB_ICONSTOP);
      end
      else
      begin
        ExitWindowsEx(EWX_FORCE or EWX_SHUTDOWN, 0);
      end;
      exit;
    end;
  end;
  MessageBox(0, 'Access denied', nil, MB_OK or MB_ICONSTOP);
end;








Copyright © 2004-2025 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте