- How to retrieve standard output
- Posted by Xavier on May 26th, 2005
Hi,
In my C/C++ Windows program, I am using external librairies writting in
standard output, this information can be read in DOS control. I want to
intercept this outputs to write them in a log file.
In my program, how can I retrieve standard output to intercept informations
?
Thanks
Xavier
- Posted by Sten Westerback on May 26th, 2005
"Xavier" <XNopre.anti.sp.am@netceler.com> wrote in message
news:d73sag$1lit$1@biggoron.nerim.net...
By changing the stdout of the Console to point to an Pipe. If you run tool
as an external program then CreateProcess() let you specify i/o pipes.
- Sten
- Posted by Alex Blekhman on May 26th, 2005
Xavier wrote:
For your process you can reopen standard streamt to
redirrect them to file. See freopen function description for
details. For child process you should use pipes as Sten
Westerback suggests. (Look for "Creating a Child Process
with Redirected Input and Output" article in MSDN.)
- Posted by Xavier on May 26th, 2005
Hi Alex,
Yes, "freopen" is my solution !
For information, the solution to restore previous streams is with "_dup
(fileno (stdout))" and "fdopen(old_stdout, "w")".
Thanks !!
Xavier