![]() |
Tipp 0001
|
Windows herunterfahren und neu starten
|
 |
|
Autor/Einsender: Datum: |
|
Detlev Schubert 25.12.2000 |
|
Entwicklungsumgebung: |
|
VB 5 |
|
|
Wenn mit dem Beenden eines Programms auch direkt Windows mit beendet werden soll, oder nach der
Änderung einer Systemeinstellung, bei der Rechner ja bekanntlich neu gebootet werden muss,
bietet die API-Funktion ExitWindows bei 16-bit oder ExitWindowsEx bei
32-bit die notwendige Unterstützung.
|
|
|
Option Explicit
#If Win16 Then
Private Declare Function ExitWindows Lib "User" _
(ByVal dwReturnCode As Long, ByVal wReserved _
As Integer) As Integer
#Else
Private Declare Function ExitWindowsEx Lib "user32" _
(ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
#End If
Dim Aktion As Long
Dim MsgBoxTxt As Long
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 1
#If Win16 Then
If MsgBox("Windows wirklich beenden?", 4 + 32 + 256, _
"Windows beenden") = vbYes Then ExitWindows 0&, 0&
#Else
If MsgBox(MsgBoxTxt &"?", 4 + 32 + 256, _
"Windows beenden")= vbYes Then
If WinNeustart(Aktion) = 1 Then _
MsgBox MsgBoxTxt & " zur Zeit nicht möglich!"
End if
#End If
Case Else
Unload Me
End
End Select
End Sub
Private Sub Option1_Click(Index As Integer)
Command1(1).Enabled = True
#If Win16 Then
Exit Sub
#End If
MsgBoxTxt = Option1(Index).Caption
Select Case Index
Case 0
Aktion = EWX_SHUTDOWN
Case 1
Aktion = EWX_REBOOT
Case 2
Aktion = EWX_LOGOFF
End Select
End Sub
Private Function WinNeustart(Aktion As Long) As Long
WinNeustart = ExitWindowsEx(Aktion, 0&)
End Sub
|
|
|
|
|
Windows-Version |
95 |
 |
|
98/SE |
 |
|
ME |
 |
|
NT |
 |
|
2000 |
 |
|
XP |
 |
|
Vista |
 |
|
Win
7 |
 |
|
|
VB-Version |
VBA 5 |
 |
|
VBA 6 |
 |
|
VB 4/16 |
 |
|
VB 4/32 |
 |
|
VB 5 |
 |
|
VB 6 |
 |
|
|
|
Download (2,2 kB)
|
Downloads bisher: [ 3507 ]
|
|
|