Fórum Como desligar o xp? #167153
30/06/2003
0
valeu pessoal.
Ål£×äñðrëðþt
Curtir tópico
+ 0Posts
02/07/2003
Ål£×äñðrëðþt
Gostei + 0
02/07/2003
Rabitz
Gostei + 0
03/07/2003
Ål£×äñðrëðþt
Gostei + 0
04/07/2003
Lfernandos
//por Luiz Fernando Severnini
function ShutDownWindows(Opcao: Byte):Boolean;
var
hToken : THandle;
pPrivileges : TTokenPrivileges;
pOldPrivileges: TTokenPrivileges;
Zero: DWord;
ptZero: DWord;
tResult: Boolean;
begin
//Checa a versão do Windows
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
tResult := OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken);
if tResult then
tResult := LookupPrivilegeValue(nil, ´SeShutdownPrivilege´, pPrivileges.Privileges[0].Luid);
pPrivileges.PrivilegeCount := 1;
pPrivileges.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
Zero := 0;
ptZero := SizeOf(pOldPrivileges);
if tResult then
Windows.AdjustTokenPrivileges(hToken,
False,
pPrivileges,
ptZero,
pOldPrivileges,
Zero);
end;
case Opcao of
//Desliga
//SHUTDOWN
0: begin
Result := ExitWindowsEx(EWX_SHUTDOWN or EWX_FORCE, 0);
end;
//Reinicia
//REBOOT
1: begin
Result := ExitWindowsEx(EWX_REBOOT or EWX_FORCE, 0);
end;
//LogOff do usuário atual
//LOGOFF
2: begin
Result := ExitWindowsEx(EWX_LOGOFF or EWX_FORCE, 0);
end;
//Desliga, mas o sistema precisa ter o recurso de Power-Off
//POWER OFF
3: begin
Result := ExitWindowsEx(EWX_POWEROFF or EWX_FORCE, 0);
end;
else begin
Result := False;
Exit;
end;
end;
end;
Parâmetros
0 - SHUTDOWN
1 - RESTART
2 - LOGOFF
3 - POWER OFF
Gostei + 0
04/07/2003
Lfernandos
//por Luiz Fernando Severnini
function ShutDownWindows(Opcao: Byte):Boolean;
var
hToken : THandle;
pPrivileges : TTokenPrivileges;
pOldPrivileges: TTokenPrivileges;
Zero: DWord;
ptZero: DWord;
tResult: Boolean;
begin
//Checa a versão do Windows
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
tResult := OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken);
if tResult then
tResult := LookupPrivilegeValue(nil, ´SeShutdownPrivilege´, pPrivileges.Privileges[0].Luid);
pPrivileges.PrivilegeCount := 1;
pPrivileges.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
Zero := 0;
ptZero := SizeOf(pOldPrivileges);
if tResult then
Windows.AdjustTokenPrivileges(hToken,
False,
pPrivileges,
ptZero,
pOldPrivileges,
Zero);
end;
case Opcao of
//Desliga
//SHUTDOWN
0: begin
Result := ExitWindowsEx(EWX_SHUTDOWN or EWX_FORCE, 0);
end;
//Reinicia
//REBOOT
1: begin
Result := ExitWindowsEx(EWX_REBOOT or EWX_FORCE, 0);
end;
//LogOff do usuário atual
//LOGOFF
2: begin
Result := ExitWindowsEx(EWX_LOGOFF or EWX_FORCE, 0);
end;
//Desliga, mas o sistema precisa ter o recurso de Power-Off
//POWER OFF
3: begin
Result := ExitWindowsEx(EWX_POWEROFF or EWX_FORCE, 0);
end;
else begin
Result := False;
Exit;
end;
end;
end;
Parâmetros
0 - SHUTDOWN
1 - RESTART
2 - LOGOFF
3 - POWER OFF
Gostei + 0
04/07/2003
Lfernandos
//por Luiz Fernando Severnini
function ShutDownWindows(Opcao: Byte):Boolean;
var
hToken : THandle;
pPrivileges : TTokenPrivileges;
pOldPrivileges: TTokenPrivileges;
Zero: DWord;
ptZero: DWord;
tResult: Boolean;
begin
//Checa a versão do Windows
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
tResult := OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken);
if tResult then
tResult := LookupPrivilegeValue(nil, ´SeShutdownPrivilege´, pPrivileges.Privileges[0].Luid);
pPrivileges.PrivilegeCount := 1;
pPrivileges.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
Zero := 0;
ptZero := SizeOf(pOldPrivileges);
if tResult then
Windows.AdjustTokenPrivileges(hToken,
False,
pPrivileges,
ptZero,
pOldPrivileges,
Zero);
end;
case Opcao of
//Desliga
//SHUTDOWN
0: begin
Result := ExitWindowsEx(EWX_SHUTDOWN or EWX_FORCE, 0);
end;
//Reinicia
//REBOOT
1: begin
Result := ExitWindowsEx(EWX_REBOOT or EWX_FORCE, 0);
end;
//LogOff do usuário atual
//LOGOFF
2: begin
Result := ExitWindowsEx(EWX_LOGOFF or EWX_FORCE, 0);
end;
//Desliga, mas o sistema precisa ter o recurso de Power-Off
//POWER OFF
3: begin
Result := ExitWindowsEx(EWX_POWEROFF or EWX_FORCE, 0);
end;
else begin
Result := False;
Exit;
end;
end;
end;
Parâmetros
0 - SHUTDOWN
1 - RESTART
2 - LOGOFF
3 - POWER OFF
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)