Results 1 to 3 of 3

Thread: How to shut down the computer

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    15

    How to shut down the computer

    How to shut down the system using vb.
    if we select the time to shut down it should close all the application and then it should shut down.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: How to shut down the computer

    Moved from FAQ section

  3. #3
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: How to shut down the computer

    I knew that Classic VB should be first, cause new comers would get confused. Anyways this is how:

    VB Code:
    1. Const EWX_LOGOFF = 0
    2. Const EWX_SHUTDOWN = 1
    3. Const EWX_REBOOT = 2
    4. Const EWX_FORCE = 4
    5.  
    6. Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
    7.  
    8. Private Sub Form_Load()
    9.  
    10.     msg = MsgBox("This program is going to reboot your computer. Press OK to continue or Cancel to stop.", vbCritical + vbOKCancel + 256, App.Title)
    11.  
    12.     If msg = vbCancel Then Unload Me
    13.  
    14.     ExitWindowsEx EWX_FORCE Or EWX_SHUTDOWN, 0
    15.  
    16. 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