Ver Mensaje Individual
  #1  
Antiguo 23-11-2006
JoeyJordison JoeyJordison is offline
No confirmado
 
Registrado: oct 2006
Posts: 68
Reputación: 0
JoeyJordison Va por buen camino
Problema con ExitWindowsEx

Hola tengo un problema para apagr pcs bajo winxp y 2000, se que tengo que obtener los permisos para apagar la pc pero ya lo he hecho, y solo me cierra la sesión este es el código que tengo:

Código Delphi [-]
var
hToken: THANDLE;
tkp, tkDumb: TTokenPrivileges;
DumbInt: DWord;
begin
FillChar(tkp, sizeof(tkp), 0);
if not (OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken)) then
raise Exception.create('OpenProcessToken falló con el código ' +
inttostr(GetLastError));
LookupPrivilegeValue(nil, pchar('SeShutdownPrivilege'),tkp.Privileges[0].Luid);
tkp.PrivilegeCount := 1;
tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, false, tkp, sizeof(tkDumb), tkDumb,DumbInt);
if GetLastError <> ERROR_SUCCESS then
raise Exception.create('AdjustTokenPrivileges falló con el código ' +
inttostr(GetLastError));
if not ExitWindowsEx(EWX_POWEROFF, 0) then
raise Exception.create('ExitWindowsEx falló con el código ' +inttostr(GetLastError));
end;

Última edición por dec fecha: 23-11-2006 a las 05:42:29.
Responder Con Cita