Unable to write to console screen from C++ DLL
I want to print messages onto the console screen from a C++ DLL. The front end for this application is in C#. I used AllocConsole() fundtion to create a console from the C++ DLL. The window is being created but no messages were being printed when I try to print a message. Please help me fix this problem.
Thanks, Rakesh开发者_如何学编程.
You need to redirect your output stream to the newly created console.
freopen("conin$", "r+t", stdin);
freopen("conout$", "w+t", stdout);
freopen("conout$", "w+t", stderr);
In your case you'd have to check this: http://www.halcyon.com/~ast/dload/guicon.htm
If you are using printf I think you should also set the stdout handle using SetStdHandle. See http://www.codeguru.com/forum/showthread.php?t=267713)
精彩评论