Buscar

Procedure para desligar ou reiniciar windows xp

Código

Procedure DesligaWindows(Reboot:Boolean);
{ Para Windows XP}
var
nov,ant:TOKEN_PRIVILEGES;
C,Tok:Cardinal;
begin
  OpenProcessToken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES+TOKEN_QUERY,Tok);
  LookupPrivilegeValue('','SeShutdownPrivilege',ant.Privileges[0].Luid);
  ant.PrivilegeCount:=1; nov.PrivilegeCount:=1;
  nov.Privileges[0].Luid:=ant.Privileges[0].Luid;
  nov.Privileges[0].Attributes:=SE_PRIVILEGE_ENABLED;
  if AdjustTokenPrivileges(Tok,false,nov,16,ant,C)then
    if Reboot then ExitWindowsEx(EWX_REBOOT+EWX_FORCE,0)
      else ExitWindowsEx(EWX_SHUTDOWN+EWX_FORCE,0);
end;

Publicidade

Vote na dica




Quantidade de votos: 0 votos
Aceitação: 0%


Detalhes da dica

Categoria: Windows
Adicionada dia: 01/05/07
Por: Fernando A Rabelo
Visualizada: 2610 vezes

Planeta Delphi - Tudo sobre programação Delphi Planeta Delphi - www.planetadelphi.com.br - Todos os direitos reservados | Copyright 2001-2009