By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Shut Down Computer in VB6

P: 24
Hi all, I try to shut down computer for security module developemnt. I used the following code, But its doesnt work also no error message come, Could you please clarify whicj way I can proceed? Thx a lot.

Const EWX_LogOff As Long = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindows _
Lib "User32" Alias "ExitWindowsEx" _
(ByVal dwOptions As Long, ByVal dwReserved As Long) As Long


Private Sub CommandButton3_Click()


'Shut down windows
ExitWindows EWX_SHUTDOWN, &HFFFFFFFF


End Sub
Apr 24 '08 #1
Share this Question
Share on Google+
2 Replies


zerok666
P: 25
if you are using xp, then this is a little bit easyer to use:

Shell "shutdown -X", vbHide

replace the -X with the one you want:

-s
shutdow
-r
restart
-l
logoff
Apr 24 '08 #2

100+
P: 283
Hi all, I try to shut down computer for security module developemnt. I used the following code, But its doesnt work also no error message come, Could you please clarify whicj way I can proceed? Thx a lot.

Const EWX_LogOff As Long = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindows _
Lib "User32" Alias "ExitWindowsEx" _
(ByVal dwOptions As Long, ByVal dwReserved As Long) As Long


Private Sub CommandButton3_Click()


'Shut down windows
ExitWindows EWX_SHUTDOWN, &HFFFFFFFF


End Sub
all the code that I have seen to import the shutdown functions has also included changing the process token to give the required access for this so that may be why your code is not working.
Apr 25 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.