Option Explicit
'Change the combo1 style property to "2 - Dropdown list" from
'the properties window manually.
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Const EWX_RESET = EWX_LOGOFF + EWX_FORCE + EWX_REBOOT
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Command1_Click()
If Combo1.ListIndex = 0 Then ' If restart option is selected
ExitWindowsEx EWX_RESET, 0&
ElseIf Combo1.ListIndex = 1 Then 'If Log off option is selected
ExitWindowsEx EWX_LOGOFF, 0&
ElseIf Combo1.ListIndex = 2 Then 'If Shut down option is selected
ExitWindowsEx EWX_SHUTDOWN, 0&
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "Restart Windows"
Combo1.AddItem "Log off Windows"
Combo1.AddItem "Shut down Windows"
Combo1.ListIndex = 0
End Sub