Posto sve kodove koje nadjem na internetu a da su zanimljivi sejvujem, imam ovaj
function ShutdownNTplatform:boolean;
const
ADJUST_PRIV = TOKEN_QUERY or TOKEN_ADJUST_PRIVILEGES;
SHTDWN_PRIV = 'SeShutdownPrivilege';
PRIV_SIZE = sizeOf(TTokenPrivileges) ;
var
Len: DWORD;
TokenPriv, Dummy: TTokenPrivileges;
Token: THandle;
Text,
Machine:array [0..128] of Char;
Force,Reboot:boolean;
Error:integer;
begin
Error := 0;
if not OpenProcessToken(GetCurrentProcess(), ADJUST_PRIV, Token) then
Error := Error or 4;
{ ShowMessage('OpenProcessToken failed') ; }
if not LookupPrivilegeValue(nil, SHTDWN_PRIV,TokenPriv.Privileges[0].Luid) then
Error:=Error or 8;
{ ShowMessage('LookupPrivilegeValue failed') ; }
TokenPriv.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
TokenPriv.PrivilegeCount := 1; // One privilege to set
if not AdjustTokenPrivileges(Token, false, TokenPriv, PRIV_SIZE,Dummy, Len) then
Error:=Error or 16;
{ ShowMessage('AdjustTokenPrivileges failed') ; }
StrPCopy(Text,FMessage) ;
StrPCopy(Machine,FMachineName) ;
InitiateSystemShutDown (Machine,Text,FTimeOut,True,False) ;
Result := (Error = 0) ;
end;
Nisam ga isprobavao..........
|