Results 1 to 2 of 2

Thread: Exit Windows Command........How?

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    52

    Question

    HI,
    I am writing an application for logging staff PC activities. Part of the login process is a screen requiring for a password, if the result is returned negative (Wrong) i want the computer after 3 false tries to restart windows.

    I know there is a way of cammanding a Dll with a switch to restart windows unprompted.
    Does anyone know what the name of that Dll is and what the code to run it is?

    Any help would be appreciated.

    Regards
    Morpheus
    (VB6 Pro Edition)

  2. #2
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408
    Got this code from vb-square.

    Code:
    '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
    But for it to work the way you want to I suggest modifying it to this:

    Code:
    '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
    
    
    'Call reboot without any prompting when they have tried 3 times and failed
    Call ExitWindowsEx(EWX_REBOOT, 0)
    Unload Me
    Hope this helps!!!
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

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