You have a couple of options. One is to redirect the standard input and
output devices for the image that you spawn to pipes that you created in
advance. You read from the "child's" output device to receive his output.
You write to his input device to force feed him input.
The technique is described here:
Another way to approach the problem is use CreateProcess() with the
CREATE_NO_WINDOW option. If you do this you won't be able to trap the output
but if the child exits by setting a status code you can retrieve it by
calling GetExitCodeProcess(). If the agreed upon code is a system error code
or one in a private message file you can get the text to go with the message
by calling FormatMessage().
See the pipe technique above.
IMO, this is a hackneyed tired old technique. It's far better to invoke an
API to perform a task than to "shell out" and resort to what amounts to
screen scraping. YMMV.