How to find the associated program for a file
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 'System & API - How to find the associated program for a file 'This function will find the executable associated with a file Option Explicit Private Const MAX_FILENAME_LEN = 256 Private Declare Function FindExecutableA Lib "shell32.dll" (ByVal lpFile As String, _ ByVal lpdirectory As String, ByVal lpResult As String) As Long Public Function FindExecutable(ByVal sFile As String) As String Dim I As Integer Dim sExe As String sExe = String(MAX_FILENAME_LEN, 32) & Chr$(0) I = FindExecutableA(sFile & Chr$(0), vbNullString, sExe) If I > 32 Then FindExecutable = Left$(sExe, InStr(sExe, Chr$(0)) - 1) Else FindExecutable = "" End If End Function |