?
Solved

opening other exe's from VB6

Posted on 2003-02-22
9
Medium Priority
?
264 Views
Last Modified: 2010-05-01
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
0
Comment
Question by:Samos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 100 total points
ID: 7998736
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
 
LVL 18

Assisted Solution

by:Sethi
Sethi earned 100 total points
ID: 7998974
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
 
LVL 18

Expert Comment

by:Sethi
ID: 7998975
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 18

Expert Comment

by:Sethi
ID: 7998978
Sorry about two clicks ;)
0
 

Expert Comment

by:pkmnfrk
ID: 7999730
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
 

Expert Comment

by:diossito
ID: 8001735
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
 

Expert Comment

by:diossito
ID: 8001748
You can add the Common Dialog by clicking in Project>Components and there select "Microsoft Common Dialog Control 6.0(SP3)"
0
 

Expert Comment

by:CleanupPing
ID: 8901265
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 8964139
Moderator, my recommended disposition is:

    Split points between: bruintje and Sethi

DanRollins -- EE database cleanup volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question