Retrieve name of EXE associated with file extension
MSDN: FindExecutable Function
$SAMPLECODE$
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 #DEFINE MAX_PATH 260 DECLARE INTEGER FindExecutable IN Shell32 ; STRING lpFile, STRING lpDirectory, STRING @lpResult * File extension for which to find associated program lcFileExt = ".pdf" * A file with specified extension is required. Creating temporary one. lcTempFile = ADDBS(SYS(2023)) + SYS(2015) + lcFileExt STRTOFILE("*", lcTempFile ) lcBuffer = SPACE(MAX_PATH) lnExeHandle= FindExecutable(lcTempFile, "", @lcBuffer) DO CASE CASE lnExeHandle > 32 lcExeName = LEFT(lcBuffer, AT(CHR(0), lcBuffer)-1) CASE lnExeHandle= 31 * No program associated with this extension lcExeName = "" ? "There is no association for the specified file type" OTHERWISE * Some other error lcExeName = "" ? lnResult ENDCASE ? lcExeName ERASE (lcTempFile)
Comments