![]() |
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? |
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. |
hola nuevamente
muchas gracias por tu ayuda. en Windows Xp funciona perfectamente. gracias nuevamente |
A menudo lo podía hacer cuando empezaba a programar, desgraciadamente no guardé las rutinas ;)
|
| La franja horaria es GMT +2. Ahora son las 23:48:33. |
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