Code Snippets

  

Visual Basic Source Code


Welcome to Dream.In.Code
Become a VB Expert!

Join 149,063 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,265 people online right now. Registration is fast and FREE... Join Now!





Shutdown Computer from VB

Shows how to Shutdown,LogOff and Force Shutdown using VB

Submitted By: born2c0de
Actions:
Rating:
Views: 38,491

Language: Visual Basic

Last Modified: December 27, 2008

Snippet


  1. ' SHUT DOWN AND RESTART IN VB6
  2.        Const EWX_LogOff As Long = 0
  3.        Const EWX_SHUTDOWN As Long = 1
  4.        Const EWX_REBOOT As Long = 2
  5.        Const EWX_FORCE As Long = 4
  6.        Private Declare Function ExitWindows _
  7.                Lib "User32" Alias "ExitWindowsEx" _
  8.                (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long
  9.      
  10.      Private Sub Command1_Click()
  11.  
  12.           'Shut down windows
  13.           ExitWindows EWX_SHUTDOWN, &HFFFFFFFF
  14.      
  15.      
  16.      End Sub
  17.      
  18.      Private Sub Command2_Click()
  19.      
  20.          
  21.           ExitWindows EWX_REBOOT, &HFFFFFFFF
  22.      
  23.      
  24.      End Sub
  25.      
  26.      
  27.  
  28.  

Copy & Paste


Comments


shankarpatil 2008-08-19 04:34:31

hi sir, iam shankar patil from - kolhapur disctic please me option button socurce code vb 6.0 in a program. example : exam form & 4 option button, then click the one button msgbox("you are wrong answer?" & "You are carrect answer?")

kasc 2008-10-26 15:24:39

this is a task i've been trying to solve but i need it in VB.net 2005. my e-mail kasc4u@gmail.com i will be greatful to have the solution. thank you

Ricendithas 2008-12-26 19:18:56

Hello there, I was wondering, how come only logoff only works while the others don't?

born2c0de 2008-12-27 08:19:38

Fixed. It should work now.


Add comment


You must be registered and logged on to </dream.in.code> to leave comments.




Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month