I have an application from where I suppose to run another console based exe and read the output of that console application? Assume the console application is third party exe which writing it using printf
.
Asked
Active
Viewed 1,271 times
0
-
2You can do this with `CreateProcess` - see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx – benjymous Dec 19 '13 at 10:11
-
Currently I am using CreateProcess to launch third party exe but the link say I have make changes in the childExe also. Means here in Third party exe which is not possible. – CrazyC Dec 19 '13 at 10:13
-
1@CrazyC AFAIK, you don't need to modify the child exe. Where does it say that? (The bit with pipe communication in the example is for the specific example - the `printf` should also show up in the parent.) – molbdnilo Dec 19 '13 at 10:53
1 Answers
0
Use CreateProcess()
to run the console app, then you can use the STARTUPINFO
struct to specify your own STDIN/OUT/ERR handles for the console to use. Create anonymous pipes via CreatePipe()
for that purpose, then you can read/write the pipes using ReadFile()
and WriteFile()
as needed.
There is an example on MSDN:

Remy Lebeau
- 555,201
- 31
- 458
- 770