ExitWindowsEx(EWX_REBOOT,0);

mathiasgautier Messages postés 1 Date d'inscription lundi 21 avril 2003 Statut Membre Dernière intervention 3 juin 2003 - 3 juin 2003 à 20:03
cs_klem Messages postés 30 Date d'inscription vendredi 25 octobre 2002 Statut Membre Dernière intervention 27 septembre 2005 - 3 juin 2003 à 22:45
procedure TForm1.Button2Click(Sender: TObject);
begin
ExitWindowsEx(EWX_REBOOT,0);
end;

end.

k est ce qui kloche ds mon code. kan je click sur mon bouton il ne fai rien

pourkoi?

1 réponse

cs_klem Messages postés 30 Date d'inscription vendredi 25 octobre 2002 Statut Membre Dernière intervention 27 septembre 2005
3 juin 2003 à 22:45
question courte réponse (...tentative) courte : cette fonction ne marche que sous win95/98 pour 2000/NT, c'est un peu plus compliqué :-p

voilà une petite procedure trouvée en source sur ce site (pas de moi)

procedure FermerWindows(bReboot: boolean);
var
sTokenIn,sTokenOut : TTOKENPRIVILEGES ;
dwLen : DWORD ;
hCurrentProcess,hToken : THANDLE ;
Luid1 : TLargeInteger ;
osVer: OSVERSIONINFO;
begin
try
hCurrentProcess := GetCurrentProcess ;
//ajuste les privilèges, necessaire pour windows XP
OpenProcessToken (hCurrentProcess,TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,hToken);
LookupPrivilegeValue(nil,'SeShutdownPrivilege',Luid1) ;
sTokenIn.PrivilegeCount := 1;
sTokenIn.Privileges[0].Luid := Luid1;
sTokenIn.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,FALSE,sTokenIn,sizeof(TTOKENPRIVILEGES),sTokenOut,dwLen);
CloseHandle (hToken);
finally
application.ProcessMessages;
//redémarre
if bReboot
then ExitWindowsEx(EWX_REBOOT or EWX_FORCEIFHUNG, 0)
else begin
//arrêt
osVer.dwOSVersionInfoSize := Sizeof(osVer);
GetVersionEx(osVer);
if osVer.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS
//test pour la version de windows (9x ou XP)
then ExitWindowsEx(EWX_SHUTDOWN or EWX_FORCEIFHUNG , 0)
else ExitWindowsEx(EWX_POWEROFF or EWX_FORCEIFHUNG , 0);
end;
end;

voilà...

bonn' prog'

klm
0
Rejoignez-nous