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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assosiated programs 1

Status
Not open for further replies.

robdon

Programmer
May 21, 2001
252
ES
Hi,

How do I find out what a certain file extension has assosiated to it.

IE. on my PC I have assosicated .mp3 files to winamp.exe

How do I get the 'winamp.exe' strings back into VB?

Thanks,

Rob Donovan
 
Hi Rob.
Do you want to get a string containing the executable file associated to that file type or do you actually want to open a file with it's associated program?
If the first I'm not sure on how to do it, but I think I've seen something about that somewhere, if the latter you can use the ShellExecute command to open a file with it's associated program.
 
Hi,

The 2nd option is what I'm after.

I'm using VB5 and there does not seem to be a ShellExecute command.

In VB5 there is a Shell command, but it does not like it if I just pass it the .mp3 file name.

I get the error 'Invalid procedure call or argument'

Rob D
 
ok try to do this:

On your code module add:

Option Explicit

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

Public Function OpenyourFile(strUrl As String) As Long
Dim hWnd As Long

OpenyourFile = ShellExecute(hWnd, vbNullString, strUrl, vbNullString, vbNullString, vbNormalFocus)

End Function

Then on a control of your form add something like:

Private Sub Command1_Click()

OpenyourFile ("Full_Path_of_your_file")

End Sub

This should work with any file.
Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top