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:
01051215
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.


>>My application does the following.
>>Before the interface comes up it asks the users computer where is the executable for all of the programs that the application may need. Such as PDF, DOC, TXT, HTM, etc. I do this by using a call asking the Users Computer what program is brought up when a certain extension (PDF, etc..) is encountered. I then store the results into a Application Object, to be used later. If this is what you have in mind then I will be glad to send you the code.
>>
>Hi Bret,
>
>I was thinking in this direction. Actually, I was gathering some ideas for my colleague's program. I am not sure how MereMortals stores some user's defined information. We'll discuss it tomorrow with my colleague. One it's quite certain, though: the program should not fail immediatelly if the program is not found in its default directory, it may prompt the user as your program does and Sergey suggested.
Bret Hobbs

"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform