This code will tell you what is the program that opens certain file type, for example:
If WinAmp is openning when you double click on MP3 file, then this code will return "C:\Program Files\WinAmp\Winamp.exe" .
Public Function GetAssociatedProgram(ByVal _
Extension
As String) As String
Dim Path As String
Dim FileName As
String
Dim nRet As Long
Const
MAX_PATH As Long = 260
'Create a temporary file
Path =
String$(MAX_PATH, 0)
If
GetTempPath(MAX_PATH, Path) Then
FileName =
String$(MAX_PATH, 0)
If GetTempFileName(Path, "~", 0,
FileName)
Then
FileName = Left$(FileName,
_
InStr(FileName, vbNullChar) - 1)
'Rename it to use supplied
extension
Name FileName As Left$(FileName,
_
InStr(FileName, ".")) &
Extension
FileName = Left$(FileName,
_
InStr(FileName, ".")) &
Extension
'Get name of associated
EXE
Path = String$(MAX_PATH, 0)
Call
FindExecutable(FileName,
_
vbNullString,
Path)
GetAssociatedProgram = Left$(
_
Path, InStr(Path, vbNullChar) - 1)
'Delete the temporary
file
Kill FileName
End If
End If
End Function
Private Sub Form_Load()
' Replace
the "MP3" below with the file extention you want to check
' Its default program
MsgBox
GetAssociatedProgram("MP3")
End Sub