Delphi - Apagar el sistema con API´S

 
Vista:

RE:aqui va lo que yo uso

Publicado por Israel (8 intervenciones) el 12/03/2002 05:48:52
procedure ApagarEquipo;
var hdlProcessHandle:THandle;
hdlTokenHandle:cardinal;
tmpLuid:TLargeInteger;
tkp,tkpNewButIgnored:TTokenPrivileges;
lBufferNeeded:DWord;
tokenBol:BOOL;
begin
hdlProcessHandle := GetCurrentProcess;
OpenProcessToken (hdlProcessHandle, (TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY), hdlTokenHandle);
//Get the LUID for shutdown privilege.
LookupPrivilegeValue(\'\', \'SeShutdownPrivilege\', tmpLuid);
tkp.PrivilegeCount := 1; // One privilege to set
tkp.Privileges[0].Luid := tmpLuid;
tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
//Enable the shutdown privilege in the access token of this process.
tokenBol:=False;
AdjustTokenPrivileges (hdlTokenHandle, tokenBol, tkp, DWORD(sizeof(tkpNewButIgnored)), PTokenPrivileges(@tkpNewButIgnored), lBufferNeeded);
ExitWindowsEx ( EWX_SHUTDOWN {or EWX_FORCE}, 0 );
end;

Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar