Sign in to follow this  

Creating a second console

This topic is 4372 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok how do I create a second Win32 console? I've searched on these forums and MSDN and AllocConsole() looks like a good start but it doesn't create another console window, it just uses the one that opens (that is to say when I call FreeConsole() the window closes and the app ends) So how can I create 2 console windows. I would like to use one to display debugging info. Thanks for any help.

Share this post


Link to post
Share on other sites
You can, however, spawn a new process with an attached console and use pipes to send debug information to the second process. The second process could be relatively simple; just something like:

#include <iostream>
int main(int, char **) {
std::cout << std::cin.rdbuf();
return 0;
}

You could probably modify the code in this article to do the process creation. Just keep in mind that you don't want to set the new pipe handles to be the stdin/stdout of the current process and you'll need to keep at least one handle around to write your debug text to.

Share this post


Link to post
Share on other sites
Thanks for the article. Unfortunately I can't seem to get it working the way i want, there's som stuff i don't quite understand. Could anybody give me some quick sample code that would just, say, write a string to the second console from the first, something simple like that. If i saw it in action the way i would like, i think i would be ok and be able to take what i need to learn from it. Thanks for any help.

Share this post


Link to post
Share on other sites

This topic is 4372 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this