- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a windows app using dialogs to process user information and options. This app allocates a console window and executes a child process which uses the console window for it's output. How do I capture the contents of the console window, and buffer, to save to a file or send to a printer.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you start the child process, you can use CreateProcess and specify a file handle for standrd output, or you could use ShellExecute and use redirection in the "arguments".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve for the response. I am sharing the file handles between the calling process and the child process. My question is, once the child process has finished and the console is still active, and on the screen, I would like to capture the output from the console window and save to a file or print it based on the user specification. I don't see how to do this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If the output is actually written to the console window, I don't know how to capture it. The way I've seen this done is to use a pipe for the output handle and have code in the parent process read from the pipe and write the contents both to the console and to a file.
Looking at the Platform SDK documentation, perhaps ReadConsoleOutput could help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try READCONSOLEOUTPUTCHARACTER()
If you want attributes, use READCONSOLEOUTPUT()
If you want attributes, use READCONSOLEOUTPUT()

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page