Results 1 to 5 of 5

Thread: Shutting down windows

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    Atlanta, GA
    Posts
    75
    Can someone take a look at this and give me an idea of what I might be doing incorrectly. I am trying to reboot windows from within a VB 6.0 app on a Windows NT 4.0 machine. When running it, I receive no error messages, but the machine does not seem to respond at all to the request.

    ===========================================================
    Public Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long

    Public Const EWX_REBOOT = 2
    -----------------------------------------------------------

    ExitWindowsEx EWX_REBOOT, 0
    ===========================================================

    Thanks.

    Jay D Zimmerman

  2. #2
    Hyperactive Member jeba's Avatar
    Join Date
    Feb 2000
    Posts
    265

    tip!

    Just have a look into this!

    http://www.vbapi.com/ref/e/exitwindowsex.html

    Jeba.

  3. #3
    Lively Member
    Join Date
    Apr 2000
    Location
    Hell
    Posts
    89

    Windows NT does not allow ExitWindows & ExitWindowsEx

    The above tip won't work - because you're running Windows NT. Windows NT, as a security measure, demands that programs explicitly request access to shut down the machine - if this is not done, the kernel silently ignores the shutdown request. I'm not going to go into the necessary AdjustTokenPrivileges calls; there are dozens of examples in the forum, just use the search feature.
    - Steve

    Real programmers use COPY CON PROGRAM.EXE

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    Atlanta, GA
    Posts
    75
    I took a look at the web site that you posted, but it did not work. However, via the Microsoft Knowledge Base, I did locate an article that describes the shutting down of Windows in the NT environment. I thought I would post the URL in case anyone else (a)was having the same problems or (b)wanted to keep in on file for future use. Thanks for all of your help.

    http://support.microsoft.com/support...-US&SD=gn&FR=0

    Jay D Zimmerman

  5. #5
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Talking ExitWindowsEx API function

    Just Paste this into your code & it should work.
    Code:
    Option Explicit
    Const EWX_LOGOFF = 0
    Const EWX_SHUTDOWN = 1
    Const EWX_REBOOT = 2
    Const EWX_FORCE = 4
    Public Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
    
    Private Sub Form_Load()
    Dim ret&
        'Log Off the current user.
        ret& = ExitWindowsEx(EWX_FORCE Or EWX_LOGOFF, 0)
        'Shutdown the current windows
        ret& = ExitWindowsEx(EWX_FORCE Or EWX_SHUTDOWN, 0)
        'Reboot the windows
        ret& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
        'Don't what this does? May be you can find it out...
        ret& = ExitWindowsEx(EWX_FORCE Or EWX_FORCE, 0)
    End Sub



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