Re: Possible to execute another program and capture its stdout in 'C'?
- From: ohaya <ohaya@xxxxxxx>
- Date: Sat, 16 May 2009 14:07:59 -0400
ohaya wrote:
Nathan Mates wrote:
In article <uQmnQPj1JHA.1196@xxxxxxxxxxxxxxxxxxxx>,
ohaya <ohaya@xxxxxxx> wrote:
I am working on a command line application, where it builds a command line for executing another program, and I need to be able to "capture" the stdout from that other program for processing in my app.
http://msdn.microsoft.com/en-us/library/ms682499(VS.85).aspx
should do the trick.
Nathan Mates
Nathan,
Thanks quick response and for the link. I'll take a look at it and will post back.
Later,
Jim
Hi,
In my case, I didn't want to pipe anything into the command my app is running, so I used the example code in that link, and commented out:
/*
if (argc == 1)
ErrorExit(TEXT("Please specify an input file.\n"));
g_hInputFile = CreateFile(
argv[1],
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_READONLY,
NULL);
if ( g_hInputFile == INVALID_HANDLE_VALUE )
ErrorExit(TEXT("CreateFile"));
// Write to the pipe that is the standard input for a child process.
// Data is written to the pipe's buffers, so it is not necessary to wait
// until the child process is running before writing data.
WriteToPipe();
printf( "\n->Contents of %s written to child STDIN pipe.\n", argv[1]);
*/
I also set the szCmdline:
TCHAR szCmdline[]=TEXT("dumpbin /imports C:\\WINDOWS\\system32\\drivers\\xxx.sys");
[My app is running dumpbin.exe on some of the files in system32\drivers.]
When I run the resulting .exe, I can see the output of dumpbin in the console window, and then:
->Start of parent execution.
->Contents of child process STDOUT:
->End of parent execution.
In other words, it looks like it's not getting anything from ReadFromPipe()?
Any idea what I might be doing wrong?
Thanks again,
Jim
.
- Follow-Ups:
- References:
- Prev by Date: Re: May an add-in be used in VS2003, VS2005, VS2008, ...
- Next by Date: Re: May an add-in be used in VS2003, VS2005, VS2008, ...
- Previous by thread: Re: Possible to execute another program and capture its stdout in 'C'?
- Next by thread: Re: Possible to execute another program and capture its stdout in 'C'?
- Index(es):
Relevant Pages
|