Results 1 to 4 of 4

Thread: Shutting down windows

  1. #1

    Thread Starter
    Addicted Member Sand_Hawk's Avatar
    Join Date
    Dec 2001
    Location
    The Netherlands
    Posts
    138

    Shutting down windows

    Hi,
    IO'm trying to shutdown Windows. I use these:

    Declare Function ExitWindowsEx Lib "user32" _
    (ByVal uFlags As Long, _
    ByVal dwReserved As Long) As Long
    Public Const EWX_FORCE = 4
    Public Const EWX_LOGOFF = 0
    Public Const EWX_REBOOT = 2
    Public Const EWX_SHUTDOWN = 1

    x = ExitWindowsEx(EWX_SHUTDOWN, 0)

    But when I use EWX_FORCE then I just logsoff(2000). When Shutdown is called nothing happens. What am I doing wrong?

    Sand Hawk
    - We wish to assimilate more information.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Use them together
    VB Code:
    1. ExitWindowsEx (EWX_SHUTDOWN + EWX_FORCE)

  3. #3

    Thread Starter
    Addicted Member Sand_Hawk's Avatar
    Join Date
    Dec 2001
    Location
    The Netherlands
    Posts
    138
    It still doesn't work. I use this code to shutdown windows:

    Code:
        If lTime >= lShutdownTime Then
            Unload frmNotify
            Shutdown.Interval = 0
            lResult = ExitWindowsEx(EWX_SHUTDOWN Or EWX_FORCE, 0)
        End If
    I tried "OR", "+" and "&". All don't work. What's wrong? I use VB 6 Enterprise with Service Pack 5 and running Windows 2000 with Service Pack 1(Too lazy to install 2). Anyone?

    Sand Hawk
    - We wish to assimilate more information.

  4. #4
    AnT
    Guest
    The 0 you pass as the last argument is the constant of EWX_LOGOFF. Try switching that 0 to 1, or 4, and remove the +'s and Ands and Or's and the EWX_FORCE so your code would look like this:

    VB Code:
    1. x = ExitWindowsEx(EWX_SHUTDOWN, 1)
    2.  
    3. 'Or if that doesn't work,
    4.  
    5. x = ExitWindowsEx(EWX_SHUTDOWN, 4)

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