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 29-08-2003
mrmanuel mrmanuel is offline
Miembro
 
Registrado: may 2003
Posts: 135
Poder: 21
mrmanuel Va por buen camino
urge. apagar windows XP

Hola nuevamente.

Ya he escrito anteriormente respecto a este tema. y alguien, no recuerdo el nombre, me comentó que mirase én "trucomania".

de ahi saque esto:


ExitWindowsEx(EWX_SHUTDOWN,0);
ExitWindowsEx(EWX_FORCE,0);
ExitWindowsEx(EWX_LOGOFF,0);
ExitWindowsEx(EWX_POWEROFF,0);
ExitWindowsEx(EWX_REBOOT,0);


que funciona perfectamente para win 98 y me, pero para XP, nada de nada.

a alguien se le ocurre algo?
Responder Con Cita
  #2  
Antiguo 29-08-2003
Avatar de NickName
NickName NickName is offline
Miembro
 
Registrado: may 2003
Ubicación: Guerrero, México
Posts: 96
Poder: 21
NickName Va por buen camino
Checa esto:


function TForm1.MyExitWindows(RebootParam: Longword): Boolean;
var
TTokenHd: THandle;
TTokenPvg: TTokenPrivileges;
cbtpPrevious: DWORD;
rTTokenPvg: TTokenPrivileges;
pcbtpPreviousRequired: DWORD;
tpResult: Boolean;
const
SE_SHUTDOWN_NAME = 'SeShutdownPrivilege';
begin
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
tpResult := OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,
TTokenHd);
if tpResult then
begin
tpResult := LookupPrivilegeValue(nil,
SE_SHUTDOWN_NAME,
TTokenPvg.Privileges[0].Luid);
TTokenPvg.PrivilegeCount := 1;
TTokenPvg.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
cbtpPrevious := SizeOf(rTTokenPvg);
pcbtpPreviousRequired := 0;
if tpResult then
Windows.AdjustTokenPrivileges(TTokenHd,
False,
TTokenPvg,
cbtpPrevious,
rTTokenPvg,
pcbtpPreviousRequired);
end;
end;
Result := ExitWindowsEx(RebootParam, 0);
end;

Se usa:

procedure TForm1.Button1Click(Sender: TObject);
begin
MyExitWindows(EWX_POWEROFF or EWX_FORCE);
end;

Espero te ayude en algo..

Saludos.

Última edición por NickName fecha: 29-08-2003 a las 19:50:15.
Responder Con Cita
  #3  
Antiguo 31-08-2003
mrmanuel mrmanuel is offline
Miembro
 
Registrado: may 2003
Posts: 135
Poder: 21
mrmanuel Va por buen camino
hola nuevamente

muchas gracias por tu ayuda. en Windows Xp funciona perfectamente.

gracias nuevamente
Responder Con Cita
  #4  
Antiguo 06-09-2003
humexico.org humexico.org is offline
Miembro
 
Registrado: jul 2003
Posts: 17
Poder: 0
humexico.org Va por buen camino
A menudo lo podía hacer cuando empezaba a programar, desgraciadamente no guardé las rutinas
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 23:14:03.


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