Extinction auto de l'ordinateur avec arret propre des applis et process

cs_mymic Messages postés 10 Date d'inscription jeudi 28 mars 2002 Statut Membre Dernière intervention 18 mai 2011 - 19 avril 2002 à 08:50
Neo.balastik Messages postés 796 Date d'inscription jeudi 17 mai 2001 Statut Membre Dernière intervention 5 mai 2009 - 19 avril 2002 à 14:53
Bonjour,

Je souhaiterais créer un prgramme VB qui éteind un ordinateur proprement en arretant les applications en cours dessus.
Quelqu'un s'est t'il comment faire ?

1 réponse

Neo.balastik Messages postés 796 Date d'inscription jeudi 17 mai 2001 Statut Membre Dernière intervention 5 mai 2009 7
19 avril 2002 à 14:53
Salut,

Un pt'it bout de code sympa:

'Constantes
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4

'API's
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long

Private Sub Form_Load()
msg = MsgBox("Ce programme va arrêter votre ordinateur. Appuyez sur OK pour continuer ou Cancel pour annuler l'action.", vbCritical + vbOKCancel + 256, App.Title)
If msg = vbCancel Then End

'Force tous les process à terminer et Etteint l'ordi
ret& = ExitWindowsEx(EWX_FORCE Or EWX_SHUTDOWN , 0)
End Sub

ATTENTION: pour NT ca ne doit pas marcher correctement si tu n'as pas les privilèges nécessaires... Car il y a une notion de privilège

Tchao

NéoB
0
Rejoignez-nous