Launch a file

I must launch a pdf file saved on the hard disk from a db lotus and in developerWorks I found the solution.

It works not only with pdf file.

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

Function LaunchFile( FileToLaunch ) As Boolean
REM Implements the ShellExecute Windows API
REM Returns True if successful (File exists and was able to launch the program associated with it)
REM Returns False if failure (File does not exist or was NOT able to launch the program associated with it)
LaunchFile = False
Dim iret As Long
Dim intReturnValue As Integer
iret = ShellExecute( 0, _
"Open", _
FileToLaunch, _
"", _
"c:\", _
intReturnValue = Cint( iret ) - 32
If intReturnValue > 0 Then
LaunchFile = True
LaunchFile = False
End If
End Function


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.