Calling another EXE file

Calling another EXE file

Post by Derrick Ho » Thu, 05 Jul 2007 21:04:32


Hello,

I hope you can help me, I'm, trying to find a way to call a thrid party exe
file from my program which will then sit there and wait for this other exe
file to finish (the other exe returns a value) and then my program will then
continue.

Execl closes my application and system opens a DOS windows


eg
Runs some code
Call other exe file with parameters
Wait
Run some more code
 
 
 

Calling another EXE file

Post by Ed Mulroy » Thu, 05 Jul 2007 22:10:25

I do not know if you are building for 16 bit Windows 3.1x or 32 bit Windows.

Assuming that you are building for 32 bit Windows you can start the other
executable with a call to CreateProcess. One of the arguments in the call
is the address of a structure you provide, a PROCESS_INFORMATION structure.
The variables in that structure are part of the return values from
CreateProcess.

You can then call WaitForSingleObject using the process handle. That will
allow you to detect when the executable has finished.

The specifics of the Windows API functions CreateProcess and
WaitForSingleObject can be found in the Windows API help supplied with the
compiler, win32.hlp. They also can be found online in the MS Development
Network site:
http://www.yqcomputer.com/
http://www.yqcomputer.com/

. Ed

 
 
 

Calling another EXE file

Post by Bob Gonde » Thu, 05 Jul 2007 22:23:35


What type of program are you making?
16 bit DOS?
Win16?
Win32?

spawnl() with P_WAIT

CreateProcess() with WaitForSingleObject()