In win32 programming in C:
Whats the best way to execute a win32 console program within another win32 program, and have the program that started the execution capture the output? At the moment I made the program redirect output to a file, but I am sure I must be able to open some sort of pipe?
Use the
CreateProcessWin32 API to start the child process.Pass to it a
STARTUPINFOstructure withhStdInput,hStdOutputandhStdErrorhandles set to file handles you opened (either real files or memory mapped files should work). You don’t need to specify all three, you can redirect only the ones you really need; most common case ishStdOutput.If you want to communicate with the child process (through
hStdInput), you need to wait for it to initialize by callingWaitForInputIdle.