• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 143
  • Last Modified:

Shuting down computer

How do you shut down the computer from vb5? Thanx
0
eltontennis
Asked:
eltontennis
1 Solution
 
VbmasterCommented:
You will have to use the ExitWindows API, here's what you need

  Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
  Public Const EWX_FORCE = 4
  Public Const EWX_LOGOFF = 0
  Public Const EWX_REBOOT = 2
  Public Const EWX_SHUTDOWN = 1

For example to log off you call the function with the EWX_LOGOFF constant and &HFFFFFFFF as the second parameter. Like this

  ExitWindows EWX_LOGOFF, &HFFFFFFFF
0
 
Erick37Commented:
If you need to use this on Win 2000 or Win NT, you need to do a bit more:

http://support.microsoft.com/support/kb/articles/Q176/6/95.asp
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now