Link to home
Start Free TrialLog in
Avatar of q11
q11

asked on

Get redirected output from external program

I need to:
1) spawn an external command-line program from my application;
2) hide the window;
3) redirect the output; and
4) display the redirected output in my vcl app.

1 &Ā 2 is easy to do with winexec (it is a 16-bit app) or shellexecute, but I am stuck on getting the redirected output.

Is the only way to do this really to create some temporary disk file?
ASKER CERTIFIED SOLUTION
Avatar of mocarts
mocarts

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Brr
Brr

Hi

WinExec probably does not handle redirection symbol correctly.
Execute command.com with a proper commandline including the redirection symbol instead. Remember to include the "/C" option to make command.com return without having to type "exit".
You can test the commandline at the DOS prompt first and the copy it to your program.
A similar solution is to create a batch file that executes the application and to start the batch file using WinExec -command.com will be started and closed as part of the process.

Henrik
Avatar of q11

ASKER

Exactly what was required!
I tried something similar but it wouldn't work. I think it was because I didn't use the security attr for the pipe creation.