VB computer Control

Electronics Computer Programming Q&A
Post Reply
Mike
Posts: 1813
Joined: Thu Mar 06, 2003 1:01 am
Location: Illinois
Contact:

VB computer Control

Post 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
bodgy
Posts: 1044
Joined: Tue Dec 04, 2001 1:01 am
Location: Australia
Contact:

Re: VB computer Control

Post 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
On a clear disk you can seek forever.
JMSD
Posts: 1
Joined: Thu Jul 17, 2003 1:01 am
Location: Portugal - Lisbon
Contact:

Re: VB computer Control

Post 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
Inovate... Think...Do it!
greg123
Posts: 361
Joined: Sat Sep 07, 2002 1:01 am
Location: St. John's NFLD Canada
Contact:

Re: VB computer Control

Post 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
Mike
Posts: 1813
Joined: Thu Mar 06, 2003 1:01 am
Location: Illinois
Contact:

Re: VB computer Control

Post by Mike »

Thanks, Greg!
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests