If you would like to make some extra cash for surfing the web, jump to http://www.codeoftheweek.com/paidsurf.html
In this issue we discuss how to retrieve the executable name for any file.
If you have any questions about using this module, let us know at email@example.com
This module makes it easy to get the executable associated with a particular extension. This routine is most useful for applications that have to launch filenames by their extensions. One great use for this function is to automatically launch a browser based on a particular HTML file that might exist in your application. It could also be used to intelligently use the existing file viewers/editors already installed on a users machine (such as looking for the default editor for the DOC extension).
Public Function FindAssociation(sFilename As String, Optional bWithParams As Boolean = False) As String
This routine does all the work of calling the FindExecutable API call to determine the program/executable associated with the extension specified in sFilename. This function requires the file to exist to determine the executable name. The bWithParams is an optional parameter that allows you to control what kind of data gets returned. If bWithParams is not specified or False only the executable path and filename will be returned. If it is True then any additional parameters or command line information will be returned. Typically the full executable filename along with any startup parameters and the file to launch will be returned as a single string.
NOTE: The FindExecutable API call seems to have a problem returning the full parameters when there is a space (blank character) in the executable filename. Use the bWithParams with caution in this case.
Public Function ReverseInstr(sStringToSearch As String, _ sStringToFind As String, _ Optional Compare As VbCompareMethod = vbBinaryCompare) As Long
See Issue #61 for details - http://www.codeoftheweek.com/issues/0061.html
Public Function ReplaceChars(sItemData As String, sSrc As String, sDest As String) As String
See Issue #9 for details - http://www.codeoftheweek.com/issues/0009.html
Shows how to retrieve the executable associated with JPG files:
Debug.Print FindAssociation("C:\WINDOWS\HELP\iis\htm\tutorial\nyc.JPG", False) ' will return: ' C:\PROGRA~1\INTERN~1\iexplore.exe Debug.Print FindAssociation("C:\WINDOWS\HELP\iis\htm\tutorial\nyc.JPG") ' will return: ' C:\PROGRA~1\INTERN~1\iexplore.exe "C:\WINDOWS\HELP\IIS\HTM\TUTORIAL\NYC.JPG"
To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address: http://www.codeoftheweek.com/membersonly/bi/0123.html
If you would like to get paid for surfing the web, jump to http://www.codeoftheweek.com/paidsurf.html