Club Delphi  
    Paypal   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

 
 
Herramientas Buscar en Tema Desplegado
  #4  
Antiguo 06-04-2006
Avatar de Lepe
[Lepe] Lepe is offline
Miembro Premium
 
Registrado: may 2003
Posts: 7.424
Poder: 31
Lepe Va por buen camino
Código Delphi [-]
function TFrmteclas.ShutDownWindows(Flag: Word): Boolean;
var
  TokenPriv: TTokenPrivileges;
  H:         DWord;
  HToken:    THandle;
begin
  if Win32Platform = VER_PLATFORM_WIN32_NT then
  begin
    OpenProcessToken(GetCurrentProcess,
      TOKEN_ADJUST_PRIVILEGES, HToken);
    LookUpPrivilegeValue(NIL, 'SeShutdownPrivilege',
      TokenPriv.Privileges[0].Luid);
    TokenPriv.PrivilegeCount := 1;
    TokenPriv.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
    H := 0;
    AdjustTokenPrivileges(HToken, FALSE,
      TokenPriv, 0, PTokenPrivileges(NIL)^, H);
    CloseHandle(HToken);
  end;
  Result := ExitWindowsEx(Flag, 0);
end;

Opciones:
Código Delphi [-]
  ShutDownWindows(EWX_POWEROFF); // apagar windows
  ShutDownWindows(EWX_REBOOT); // reiniciar windows

  ShutDownWindows(EWX_POWEROFF or EWX_FORCE); // forzar apagado
  ShutDownWindows(EWX_REBOOT or EWX_FORCE); // forzar reiniciado

  shutdownwindows(EWX_LOGOFF); // cerrar session

Con la opción "Forzar" ningun programa puede denegar el apagado del sistema. Si hay cambios que no se han guardado en Word, directamente se pierden

Probado en Windows XP Sp2

Saludos
__________________
Si usted entendió mi comentario, contácteme y gustosamente,
se lo volveré a explicar hasta que no lo entienda, Gracias.
Responder Con Cita
 



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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Dar privilegios del SYSDBA a otro usuario Eolo Firebird e Interbase 3 21-03-2004 05:48:15
Roles - Usuarios y privilegios Osorio Firebird e Interbase 2 13-02-2004 23:34:31
Privilegios en interbase acrophet Conexión con bases de datos 1 09-02-2004 15:07:35


La franja horaria es GMT +2. Ahora son las 04:08:28.


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