Information générale
Catégorie:
Codage, syntaxe et commandes
>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)
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement