Comment quitter ou redémarrer Windows ?
Il faut employer l'API ExitWindowsEx : Option Explicit Const EWX_LOGOFF As Long = 0 Const EWX_SHUTDOWN As Long = 1 Const EWX_REBOOT As Long = 2
Public Declare Function ExitWindowsEx Lib "user32" ( _ ByVal uFlags As Long, _ ByVal dwReserved As Long) As Long
Sub Main()
If MsgBox("Voulez-vous fermer Windows ?", vbQuestion + vbYesNo) = vbYes Then ExitWindowsEx EWX_SHUTDOWN, 0 End If End Sub Remarque : Sous Windows NT, 2000 et XP, il faut bénéficier du privilège SE_SHUTDOWN_NAME pour pouvoir employer cette API. Pour aller plus loin Voir aussi : |