Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Run a windows exe from Fox
Message
From
19/09/2001 10:25:38
Gary Foster
Pointsource Consulting LLC
Chanhassen, Minnesota, United States
 
 
To
18/09/2001 11:08:13
Denis Filer
University of Oxford
United Kingdom
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00557865
Message ID:
00558319
Views:
18
>Is there a simple way to fire up a small windows exe prog from inside my Fox app - as in the MSDOS ! and RUN commands. I know how to automate e.g. Word but can't seem to start another small exe. Createprocess?? Excuse ignorance ... and thanks.

Denis,

Here is some quick code to play with using the API that will launch an EXE and tell you(sometimes) why it didn't launch.

Gary


FUNCTION CallExe(tcExePath)

*-- Declare statement used to call EXEs
DECLARE INTEGER ShellExecute IN SHELL32 INTEGER hWinHandle,;
STRING clpOperation, STRING clpFile, STRING clpParameters,;
STRING clpDirectory, INTEGER nShowCmd

LOCAL cExePath, nResult


cExePath = tcExePath
nResult = 0

*-- Launch the EXE
nResult = ShellExecute(0,"open"+CHR(0),cExePath+CHR(0),""+CHR(0),SUBSTR(cExePath,1,RAT('\',cExePath))+CHR(0),1)

*-- Display any error messages.
DO CASE
CASE nResult= 0
MSGBOX2('Attempted Launch Failed: The system is out of memory or resources')
CASE nResult= 2
MSGBOX2('Attempted Launch Failed: The specified file {'+ cExePath + '} was not found')
CASE nResult= 3
MSGBOX2('Attempted Launch Failed: The specified path {'+ cExePath +'} was not found')
CASE nResult= 11
MSGBOX2('Attempted Launch Failed: The specified exe {'+ cExePath +'} is invalid')
CASE nResult= 26
MSGBOX2('Attempted Launch Failed: A sharing violation has occured')
CASE nResult= 27
MSGBOX2('Attempted Launch Failed: The specified filename {'+ cExePath +'} association is incomplete of invalid')
CASE nResult= 28
MSGBOX2('Attempted Launch Failed: The DDE transaction {'+ cExePath +'} could not be completed because the transaction timed out')
CASE nResult= 29
MSGBOX2('Attempted Launch Failed: The DDE transaction {'+ cExePath +'} failed')
CASE nResult= 30
MSGBOX2('Attempted Launch Failed: The DDE transaction {'+cExePath+'} could not be completed because other DDE transactions were being processed')
CASE nResult= 31
MSGBOX2('Attempted Launch Failed: The specified exe {'+ cExePath +'} has no application association')
CASE nResult= 42
*-- Good, it was called properly.
OTHERWISE
nResult = 999
MSGBOX2('Attempted Launch Failed: Reason unknown')
ENDCASE

RETURN (nResult=42)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform