Start application from vb5

Posted on 1999-10-27
Medium Priority
Last Modified: 2010-05-02
I have been using the following code to open applications from vb5.  It works on most applications and in particular a version of music match written in VB.  Their latest version was written in C++ and it won't open with this code.  I can double click on a file.m3u and it will open.  How do I need to change the code to be able to open any application within vb5?

Private Sub List3_Click()
Dim musicfil As String
musicfil = List3.Text & ".m3u"
Dim lngRetVal As Long
ShellExecute Me.hwnd, "Open", musicfil, 0&, 0&, 5
End Sub
Question by:donb1

Expert Comment

ID: 2162137
Does it give you an error?  Does it simply not run the program?

It looks like you are running a file that is associated with this executable but maybe the association is not there any longer..?

Expert Comment

ID: 2162140
It doesn't matter what the application that you are trying to launch was written in. So long as the association to that file type is made in Windows, ShellExecute will launch the appropriate EXE. If this has worked in the past and is not now, I would check that under File Types in Windows it actually specifies the application under OPEN.


Author Comment

ID: 2162159
The association is there, otherwise it would not open when I click on the file.m3u icon.  Question is, is my code correct?
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!


Expert Comment

ID: 2162170
Are you passing the FULL filename (with path)?

Accepted Solution

Juilette earned 200 total points
ID: 2162188
'open a file with it's associated application
'this example opens addin.txt with notepad
'put this in a bas module
Public Declare Function ShellEx Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As Any, _
ByVal lpDirectory As Any, ByVal nShowCmd As Long) As Long
Sub ShellDef(strFileName)
x = ShellEx(Form1.hwnd, "open", strFileName, "", "", 1)
End Sub

'>>>>>>>>>>>>>>>>> code for event on form <<<<<<<<<<<<<<<<<<<<<<<<<<
      ShellDef ("c:\my documents\addin.txt")
LVL 10

Expert Comment

ID: 2162250

Author Comment

ID: 2162285
That drag and drop is interesting but more complex than I need now.
LVL 10

Expert Comment

ID: 2162342
The drag and drop is just a feature which can be taken out without a problem. What's important is how the code takes your file extension, looks up the registry to find out what the correct action is for this extension, and then executes it.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

624 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