Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Running external program
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01051001
Message ID:
01051230
Views:
15
>In case you ever need it:
>
>LOCAL lcfile, lcdir, lcbuffer, lnresult, lnpt, lcexecutable
>
>DECLARE INTEGER FindExecutable IN Shell32  STRING @lpfile, STRING @lpdirectory, STRING @lpbuffer
>* lcfile is the file you want to find the executable for
>lcfile = THIS.cFileToFindExecutableFor
>lcdir = JUSTPATH(lcfile)
>lcbuffer = SPACE(260)
>lnresult = FindExecutable(@lcfile, @lcdir, @lcbuffer)
>* There is a known bug in the find executable function that
>* if the program was not installed properly with quotes around
>* path names with spaces then the function will put the end of
>* line character in the wrong place, so we will
>* translate the chr(0) into a space and look for the char's .EXE
>* which should be at the end of all our executables.
>IF lnresult > 31
>  lcbuffer = strtran(lcbuffer,CHR(0),' ')
>  *lnpt = AT(CHR(0), lcbuffer)
>  lnpt = AT('.EXE ', UPPER(lcbuffer))+3
>  lcexecutable = LEFT(lcbuffer, lnpt)
>ENDIF
>RETURN lcexecutable
>
>
>*
>I create dummy file names to test what executable would be used. Such as lctempfile = lchomedir+'\TEMP\'+SYS(3)+'.htm'.
>The file does not exist, I just create a name to pass to the above function call. It then returns to me the complete path to the execuatable that would be used to run the htm file.
>
>
Bret, thanks. This code will become handy for other cases.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform