Visual Basic 6: Open a program using its default application

How to open a program using its default application:

Private Declare Function ShellExecuteAny Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As Any, ByVal lpDirectory As Any, ByVal nShowCmd As Long) As Long

Private Sub Picture1_Click()
ShellExecuteAny Me.hwnd, "open", "myfile.pdf", ByVal 0&, ByVal 0&, vbNormalFocus
End Sub

Leave a Reply