local lcExec lcExec = ExecutableFound( "htm" ) if not empty( lcExec ) StartExecutable( lcExec, "http://www.viafox.nl" ) else wait window "No Internet connection available" nowait endif RETURN * ExecutableFound() will return the reference to the present executable for the file extension. * An empty return value indicates that there's no executable for that extension present. * We're not interested in the cause of a failure. However, that info *could* be given. * Parameters: * tcExtension Obliged parameter. File extension that triggers the executable. E.g. "htm", "txt", "app" * Result: * lcBrowserExec The reference (path+file) to the executable. An empty string indicates that there's * no executable for that extension present. * Changes: * 22/sep/2003 pdv Created. FUNCTION ExecutableFound lparameter tcExtension local lnResult, lcBrowserExec, lcFileName, lcFileDir, llFound lcBrowserExec = space( 255 ) lcFileName = sys( 2023 ) + sys( 3 ) + "." + m.tcExtension lcFileDir = "" strtofile( m.tcExtension, m.lcFileName ) declare integer FindExecutable in shell32.dll string, string, string * Find the application associated with the extension. lnResult = FindExecutable( @lcFileName, @lcFileDir, @lcBrowserExec ) lcBrowserExec = iif( m.lnResult >= 32, trim( m.lcBrowserExec ), '' ) *!* * Error messages if the return value is < 32 *!* DO CASE *!* case lnResult >= 32 && ok *!* CASE lnResult = 2 *!* Wait wind "Bad association, oops!" *!* CASE lnResult = 31 *!* Wait wind "No association, oops!" *!* CASE lnResult = 29 *!* Wait wind "Can't start the application, oops!" *!* CASE lnResult = 30 *!* Wait wind "The application is already started, oops!" *!* ENDCASE delete file ( m.lcFileName ) clear dlls FindExecutable RETURN m.lcBrowserExec * * * * * * * * * * * * * StartExecutable() will start an executable with the Shell32.ShellExecute("open") command. * You should have tested for the existence of the executable beforehand! * Parameters: * tcExec Name of the executable. It should be retrieved with ExecutableFound() beforehand. * tcParm Parameter for the executable. * Result: * Whether or not it succeeded in starting the executable with the parameter. * E.g.: * lcExec = ExecutableFound( "htm" ) * if not empty( lcExec ) * StartExecutable( lcExec, "http://www.viafox.nl" ) * endif * Changes: * 22/sep/2003 pdv Created. FUNCTION StartExecutable lparameter tcExec, tcParm local lnResult declare integer ShellExecute in shell32.dll ; integer nWinHandle, ; string cOperation, ; string cFileName, ; string cParameters, ; string cDirectory, ; integer nShowWindow lnResult = ShellExecute( 0, "Open", m.tcExec, m.tcParm, "", 1 ) clear dlls ShellExecute RETURN ( m.lnResult >= 32 )