November 8th, 2002, 07:30 AM
Calling another program
Have a question...
How do you call another .exe from within a command line program so that I can pass it parameters?
November 8th, 2002, 12:42 PM
CreateProcess() ought to do it.
"Me fail English? That's unpossible!"
November 8th, 2002, 01:01 PM
you can use the imho easier function ShellExecute from shell32.dll.
the syntax (from the MS Windows SDK) is:
HWND hwnd, // handle to parent window
LPCTSTR lpOperation, // pointer to string that specifies operation to perform
LPCTSTR lpFile, // pointer to filename or folder name string
LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters
LPCTSTR lpDirectory, // pointer to string that specifies default directory
INT nShowCmd // whether file is shown when opened
the only thing that was unclear to me first was "lpOperation" which should be "open"
Last edited by M.Hirsch; November 8th, 2002 at 01:10 PM.
November 8th, 2002, 01:03 PM
A portable solution would be to use popen, which allows complete command line option passing. It's generally part of stdio.h in modern compilers. As a bonus the input and output are available to the calling program.
If you want the program to present it's interface to the end user, the aforementioned CreateProcess is the way to go.
Articles and commentary on web development
November 8th, 2002, 07:18 PM
Thanks guys. I'll try to get working on these tonight if I can scrape time away from my daughter.