Retrieve name of EXE associated with file extension
By Sergey - Posted on January 1st, 2008
MSDN: FindExecutable Function
| This is sample code. Add error handling and adjust to your requirements as necessary. |
#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)
Recent comments
1 week 23 hours ago
2 weeks 1 day ago
3 weeks 2 days ago
3 weeks 3 days ago
3 weeks 5 days ago
3 weeks 6 days ago
4 weeks 4 days ago
4 weeks 4 days ago
4 weeks 5 days ago
4 weeks 5 days ago