platypus - Já to dělám takhle
procedure ShutDownWindows(Flags : Cardinal = EWX_Reboot + EWX_Force);
var
B : Boolean;
H : THandle;
NS, PS : TTokenPrivileges;
RL : dword;
Luid: TLargeInteger;
begin
B:=OpenProcessToken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES + TOKEN_QUERY,H);
B:=LookupPrivilegeValue('','SeShutdownPrivilege', Luid);
NS.PrivilegeCount := 1;
NS.Privileges [0] . Luid := Luid;
NS.Privileges [0] . Attributes := SE_PRIVILEGE_ENABLED;
RL := 0;
B:= AdjustTokenPrivileges(
H, // handle of token that contains privileges
false, // flag for disabling all privileges
NS, // address of new privilege information
SizeOf (NS), // size of previous information buffer
PS, // address of previous information
RL // address of required buffer size
);
B := ExitWindowsEx (Flags, 0);
end;
ShutDownWindows(EWX_LOGOFF + EWX_Force); //logout
ShutDownWindows; //restart
ShutDownWindows(EWX_POWEROFF or EWX_ForceIFHUNG); //shutdown
//ty flagy se daj nakombinovat asi všelijak |