Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open default external Program with VB for file playback 1

Status
Not open for further replies.

pdecker

Technical User
Jun 16, 2003
31
0
0
US
Hi,

I want to be able to open an external program with VB and send it a file. I know that the shell command works, but I want to do something more along the lines of having the user double click a file in a FileList and then the default application installed on the users machine for opening the file type that was clicked on will open and run it.

So if some one double clicks movie.avi , and media player is the default program for .avi files, it will open and play movie.avi....but if real player is the default, then real player will open and play movie.avi

Im somewhat new with VB so please be gentle, and generous, with code examples. Thanks for any help!

 
Try using the shellexecute command...
Code:
Private 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
Const SW_SHOWNORMAL = 1
Private Sub Form_Load()
    'KPD-Team 1998
    'URL: [URL unfurl="true"]http://www.allapi.net/[/URL]
    'E-Mail: KPDTeam@Allapi.net
    'Send an E-Mail to the KPD-Team
    ShellExecute Me.hwnd, vbNullString, "mailto:KPDTeam@Allapi.net", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
You can pass it a filename rather than the email address and it will use the defualt program to open it. See for more information.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top