English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I need some help with my visual basic program I would like to to reboot the computer when the user clicks a button but cant get it to work, this is what ive got so far (that dosent work):

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Shell("RUNDLL32.EXE shell32,SHExitWindowsEx 2", AppWinStyle.NormalFocus)
End Sub

RUNDLL32.EXE shell32,SHExitWindowsEx 2 is meant to reboot the computer (someone told me) but it just dosent work so does anyone know how I can do it?

2007-01-10 04:11:17 · 2 answers · asked by sbraidley 3 in Computers & Internet Programming & Design

2 answers

You need to make a Windows API call..."API" stands for "application programming interface", and is a collection of system functions not native to the visual basic environment. There are some good books on these kinds of functions. CHeck a local bookstore. Warning: incorrectly coding an API call can freeze the computer so you have to reboot.

2007-01-10 04:21:25 · answer #1 · answered by Richard H 7 · 0 0

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

Private Sub cmdShutDown()
ExitWindowsEx EWX_SHUTDOWN, 0
End Sub

2007-01-10 04:40:52 · answer #2 · answered by 3 · 2 0

fedest.com, questions and answers