Page 1 of 1

VB computer Control

Posted: Tue Jul 15, 2003 7:04 pm
by Mike
I am writing software with VB5 Pro that takes over explorer.exe in windows. It needs to be able to shut down, and restart the computer. Is there some code that will accomplish this task in win 95 - win xp? Also, since it will take over windows, is there some code that will change the system or windows .ini (I forgot which one it is) so that it loads to the program instead of explorer.exe?
Thanks, Mike

Re: VB computer Control

Posted: Wed Jul 16, 2003 4:41 am
by bodgy
Win95 there is some code that you can add as a switch to RUNDLL which I forget at this moment, I'll have to rack my brain.<p>XP is easier the shutdown program is an entity all of its own, you just have to call it, except I can't remember that one either, but a google search of XP sites will bring up that info.<p>Colin

Re: VB computer Control

Posted: Thu Jul 17, 2003 3:38 pm
by JMSD
Hi!<p>To change the system or windows .ini files run "sysedit" in the RUN command box (in Start)<p>do you already know how to restart the windows?<p>JMSD

Re: VB computer Control

Posted: Tue Jul 29, 2003 7:48 am
by greg123
Mike,<p>Here are the API function for what you requested.<p>'In general section
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: [email protected]
msg = MsgBox("This program is going to reboot your computer. Press OK to continue or Cancel to stop.", vbCritical + vbOKCancel + 256, App.Title)
If msg = vbCancel Then End
'reboot the computer
ret& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
End Sub<p>Or try this:<p>For Windows 9x use this:<p>SHUTDOWN BUTTON<p>Private Sub Command1_Click()
Shell "Rundll32.exe user,exitwindows"
End Sub<p>RESTART BUTTON<p>Private Sub Command2_Click()
Shell "rundll32.exe shell32.dll,SHExitWindowsEx 2"
End Sub<p>
For Windows 2000 and XP, I recommend you download a better alternative to the shutdown.exe used in XP.
You can do a search for it or download it from the Wintips file section if you are a member
http://groups.yahoo.com/group/WinTips-Tricks/files/
Look for shutdown2.exe
then place it in your System folder and use this code:<p>SHUTDOWN BUTTON<p>Private Sub Command1_Click()
Shell "shutdown2.exe -u -t 0"
End Sub<p>RESTART BUTTON<p>Private Sub Command2_Click()
Shell "shutdown2.exe -r -t 0"
End Sub<p>
Greg

Re: VB computer Control

Posted: Tue Jul 29, 2003 6:31 pm
by Mike
Thanks, Greg!