Shut Down Computer in VB6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shaif
    New Member
    • Mar 2008
    • 24

    Shut Down Computer in VB6

    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 "ExitWindow sEx" _
    (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long


    Private Sub CommandButton3_ Click()


    'Shut down windows
    ExitWindows EWX_SHUTDOWN, &HFFFFFFFF


    End Sub
  • zerok666
    New Member
    • Apr 2008
    • 25

    #2
    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

    Comment

    • jg007
      Contributor
      • Mar 2008
      • 283

      #3
      Originally posted by shaif
      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 "ExitWindow sEx" _
      (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.

      Comment

      Working...