Results 1 to 2 of 2

Thread: Windows Shutdown API

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Posts
    4

    Exclamation Windows Shutdown API

    I am new to this and trying to learn. I am having trouble using the Windows Shutdown API. When I try to declare the function in my code it states the the constants can't be public?

    Here is the code, where should I declare this function and how do I go about doing so...'Api function and the constants required for ExitWindowsEx
    Declare Function ExitWindowsEx& Lib "user32" (ByVal uFlags As Long, _
    ByVal dwReserved As Long)

    Public Const EWX_FORCE = 4
    Public Const EWX_LOGOFF = 0
    Public Const EWX_REBOOT = 2
    Public Const EWX_SHUTDOWN = 1

    Private Sub cmdShutdown_Click()

    Dim MsgRes As Long

    'Make sure that the user really want to shutdown
    MsgRes = MsgBox("Are you sure you want to Shut Down Windows 95?", vbYesNo Or vbQuestion)

    'If the user selects no, exit this sub
    If MsgRes = vbNo Then Exit Sub

    'else, shutdown windows and unload this form
    Call ExitWindowsEx(EWX_SHUTDOWN, 0)
    Unload Me

    End Sub

    Thanks a bunch!!

  2. #2
    jim mcnamara
    Guest
    Try:

    Code:
    Private Function ExitWindowsEx& Lib "user32" (ByVal uFlags As Long, _ 
    ByVal dwReserved As Long) 
    
    Const EWX_FORCE = 4 
    Const EWX_LOGOFF = 0 
    Const EWX_REBOOT = 2 
    Const EWX_SHUTDOWN = 1 
    
    Private Sub cmdShutdown_Click() 
    
    Dim MsgRes As Long 
    
    'Make sure that the user really want to shutdown 
    MsgRes = MsgBox("Are you sure you want to Shut Down Windows 95?", vbYesNo Or vbQuestion) 
    
    'If the user selects no, exit this sub 
    If MsgRes = vbNo Then Exit Sub 
    
    Call ExitWindowsEx(EWX_SHUTDOWN 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