Jak programowo wyłączyć windows 2000 i XP. wiem jak to zrobic w 98, ale w 2000 i XP to nie dziala. prosze op pomoc!!!
0
0
function WinExit(Flags: Cardinal): Boolean;
const
SP = 'SeShutdownPrivilege';
var
H: THandle;
C: Cardinal;
Tp: TTokenPrivileges;
begin
Result := False;
Tp.PrivilegeCount := 1;
H := GetCurrentProcess;
OpenProcessToken(H, TOKEN_ADJUST_PRIVILEGES, H);
if LookupPrivilegeValue(nil, SP, Tp.Privileges[0].Luid) then
begin
Tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
Result := AdjustTokenPrivileges(H, False, Tp, SizeOf(Tp), nil, C);
if Result then Result := ExitWindowsEx(Flags, 0);
end;
CloseHandle(H);
end;
// przykład
begin
WinExit(EWX_POWEROFF or EWX_FORCE);
end;