Results 1 to 4 of 4

Thread: ExitWindowsEx(EWX_POWEROFF, 0)

  1. #1

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    On Windows NT4, this seems to make it reboot rather than shut off. Can anyone get NT4 to power off rather than prompt for turnoff?

    Code:
    Private Enum SHUTDOWNFLAG
        EWX_LOGOFF = 0
        EWX_SHUTDOWN = 1
        EWX_REBOOT = 2
        EWX_FORCE = 4
        EWX_POWEROFF = 8
    End Enum
    Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As SHUTDOWNFLAG, ByVal dwReserved As Long) As Long
    
    Private Sub cmdPoweroff_Click()
        Dim retval As Long
        retval = ExitWindowsEx(EWX_POWEROFF, 0)
        Unload Me
    End Sub
    Thanks,
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Try this:

    Code:
    Private Sub ExitWindows()
        Dim rc As Long
        rc = ExitWindowsEx(EWX_SHUTDOWN, 0)
    End Sub

  3. #3

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    That takes you to the "It is now safe to shut off your computer" box where the user has to physically flip off the power switch, which I'm trying to avoid. It will be for NT 4.0 SP6a Workstations. MSDN says the EWX_POWEROFF is valid for NT, so I want to try to get it to work.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    I don't think this works on NT, but you can combine these :
    Code:
    Dim Retval as Long
    Retval = ExitWindowsEx(EWX_FORCE Or EWX_SHUTDOWN, 0)

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width