Hi,
could anyone give me code for shutting down, restarting and logging off windows. This is the code I have at the moment but it only works when I load it from the project. It doesn't work as an application:

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
Const EWX_FORCE = 4
Const EWX_POWEROFF = 8
Const EWX_RESET = EWX_LOGOFF + EWX_FORCE + EWX_REBOOT

Private Sub Command1_Click()
Dim X As Long
If Combo1.ListIndex = 0 Then ' If restart option is selected
X = ExitWindowsEx(EWX_RESET, dwReserved)
ElseIf Combo1.ListIndex = 1 Then 'If Log off option is selected
X = ExitWindowsEx(EWX_LOGOFF, dwReserved)
ElseIf Combo1.ListIndex = 2 Then 'If Shut down option is selected
X = ExitWindowsEx(EWX_SHUTDOWN, dwReserved)
Else 'If Else
End If
End Sub

Thanks a million to anyone who replys