Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing messages to console from C++ DLL

Tags:

c++

I have an application which uses C# for front end and C++ DLL for the logic part. I would want to print error messages on console screen from my C++ DLL even when the C# GUI is present. Please let me know how to do this.

Thanks, Rakesh.

like image 660
Rakesh K Avatar asked Mar 01 '10 06:03

Rakesh K


2 Answers

You can use AllocConsole() to create a console window and then write to standard output.

If you are using C or C++ standard I/O functions (as opposed to direct win32 calls), there are some extra steps you need to take to associate the new console with the C/C++ standard library's idea of standard output. http://www.halcyon.com/~ast/dload/guicon.htm explains what you have to do and why, with complete code.

like image 181
Greg Najda Avatar answered Oct 09 '22 13:10

Greg Najda


You can use OutputDebugString in C++ DLL, and then execute DebugView to get the messages

like image 37
Francis Avatar answered Oct 09 '22 12:10

Francis