|
-
May 25th, 2004, 07:03 AM
#1
Thread Starter
New Member
Exiting Windows
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|