opening other exe's from VB6

ive been doing a lot of c++ programming and now i have to get back into VB6 cause thats what we are programming with in school.

ive decided to make a few review programs to help me get back into my VB mode.  i want to make a program that will let me choose what game i want to run. the only problem is i cannot remember the syntax for running another exe from VB6, thanks for any help in advance
SamosAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bruintjeCommented:
Hello Samos,

Shell "FullPathAndFilenameToExecutable Parameters"

for example starting word
 
Shell "C:\Program Files\Microsoft Office\Office\Winword.exe"
or with document like
Shell "C:\Program Files\Microsoft Office\Office\Winword.exe C:\Mydoc.doc"

HAGD:O)Bruintje
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SethiCommented:
There are two of ways by which you can do this.

First Method
Use the Shell Function In VB. Here is an example:
Shell "C:\WINNT\system32\notepad.exe " & strFileName, vbMaximizedFocus
Specify the textfile name with full path in strFileName.


Second Method
Use ShellExecute API.
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
ShellExecute Me.hwnd, "Open", filePath, 0&, 0&, SW_SHOWNORMAL

Specifying Network Path with ShellExecute
strPath = "\\ABC Computer\C\My Documents\Text.txt"
0
SethiCommented:
There are two of ways by which you can do this.

First Method
Use the Shell Function In VB. Here is an example:
Shell "C:\WINNT\system32\notepad.exe " & strFileName, vbMaximizedFocus
Specify the textfile name with full path in strFileName.


Second Method
Use ShellExecute API.
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
ShellExecute Me.hwnd, "Open", filePath, 0&, 0&, SW_SHOWNORMAL

Specifying Network Path with ShellExecute
strPath = "\\ABC Computer\C\My Documents\Text.txt"
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

SethiCommented:
Sorry about two clicks ;)
0
pkmnfrkCommented:
With a listbox on a form, here is the code I would use:

'------Begining of code------

Private games as Collection 'This will hold the names and paths of the games

Private sub Form_Load()

Set games = New Collection 'Create new collection

games.add "<path of your game>", "Name of your game" 'Add as many as you want.

For each game in games 'Loop through the games
list1.add game.key 'Add the name of the game to the list box
next

end sub

private sub list1_DblClick()
Shell games(List1.List(List1.ListIndex)), vbNormalFocus 'Load the game
end sub

'------End of code------

I hope this helps!
0
diossitoCommented:
you can do that so...
Shell "Dir\*.exe", vbNormalFocus


or if you don't understandme, there is an example
Shell "C:\Windows\notepad.exe", vbNormalFocus

if you want, you can also add
Common Dialog  (Name: CommonDialog1)
Text box       (Name: txtSource)
Command button (Name: cmdSelect)
Command button (Name: cmdExecute)

And insert the following code:

Private Sub cmdSelect_Click()
    CommonDialog1.Filter = "(*.exe)|*.exe"
    CommonDialog1.ShowOpen
    If CommonDialog1.FileName <> "" Then
        txtSource.Text = CommonDialog1.FileName
    End If
End Sub

Private Sub cmdExecute_Click()
    If txtSource.Text <> "" Then
        Shell txtSource.Text, vbNormalFocus
    End If
End Sub
0
diossitoCommented:
You can add the Common Dialog by clicking in Project>Components and there select "Microsoft Common Dialog Control 6.0(SP3)"
0
CleanupPingCommented:
Samos:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
DanRollinsCommented:
Moderator, my recommended disposition is:

    Split points between: bruintje and Sethi

DanRollins -- EE database cleanup volunteer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.