Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > API de Windows
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 30-07-2004
tiel tiel is offline
Miembro
 
Registrado: jul 2003
Ubicación: México, D.F.
Posts: 29
Poder: 0
tiel Va por buen camino
Apagar PC en XP

Investigando ya sé cómo hacer que funcione la función API ExitWindowsEx en Windows XP, tienen que tener privilegios para eso, y se obtiene con la API también:

Código:
var

  hToken: THandle;           
  tkp: TTokenPrivileges;
  tkp2: PTokenPrivileges;
  r: Dword;                      //Esta variable sobra, pero se tiene que usar para pasársela a la función AdjustToken....

implementation

   if OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then

   if LookupPrivilegeValue(nil, 'SeShutdownPrivilege', tkp.Privileges[0].Luid) then
      begin

         tkp.PrivilegeCount := 1;
         tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;

         if AdjustTokenPrivileges(hToken, FALSE, tkp, 0, nil, r) then
            ExitWindowsEx( .. , 0 );
      end;
__________________
“Daría todo lo que sé por la mitad de lo que ignoro”
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 21:04:55.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi