Ver la Versión Completa : urge. apagar windows XP
mrmanuel
29-08-2003, 19:16:36
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?
NickName
29-08-2003, 20:47:47
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.
mrmanuel
01-09-2003, 00:48:07
hola nuevamente
muchas gracias por tu ayuda. en Windows Xp funciona perfectamente.
gracias nuevamente
humexico.org
06-09-2003, 06:09:24
A menudo lo podía hacer cuando empezaba a programar, desgraciadamente no guardé las rutinas ;)
vBulletin v3.6.8, Derechos ©2000-2024, Jelsoft Enterprises Ltd.