deklarace
'asociovaný program
Public Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Long
'spuštění asociovaného programu
Public 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 Const SW_MAXIMIZE = 3
'zjištění, který program je asociován na příponu souboru
Dim strFile As String, ret As Long, Soubor as String, Program as String
strFile = Space(260)
ret = FindExecutable(Soubor, "", strFile)
Program = Trim(Left(strFile, InStr(1, strFile, Chr(0)) - 1))
Program = LCase(Mid(Program, InStrRev(Program, "\") + 1))
If Program = "" Then
'Není asociován žádný program
GoTo ...nekam...
End If
'spuštění asociovaného programu
ShellExecute Me.hwnd, "open", Soubor, vbNullString, vbNullString, SW_MAXIMIZE
|