开发者

Unable to write to console screen from C++ DLL

开发者 https://www.devze.com 2022-12-22 02:38 出处:网络
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 c

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)

0

精彩评论

暂无评论...
验证码 换一张
取 消