Skip to main content
GameDev.net gamedev.net
🔒 Locked

Console using WinAPI

Started by DesignerX Jan 23, 2007 at 4:31 PM 3 replies 500+ views
Original Post
DesignerX
DesignerX
Is it possible to open a console on a Win32 API project in Visual C++ 2005 ? (Besides application's window I want the dos console for writing simple debug messages with cout/printf) thx.
There is nothing that can't be solved. Just people that can't solve it. :)
taby
taby
Consoles, including the creation of and writing to.
GamerYZ
GamerYZ
All you have to is add the following to your Win32 project:

#pragma comment( linker, "/SUBSYSTEM:CONSOLE" )int main( void ){	return WinMain( GetModuleHandle( NULL ), NULL,		GetCommandLine(), SW_SHOWDEFAULT );}


This will create a console window along with the win32 window(assuming you set up everything right with creating the win32 window). After that you can just use cout any where to print stuff to console window.
Colin Jeanne
Colin Jeanne
Quote:
Original post by GamerYZ
All you have to is add the following to your Win32 project:

*** Source Snippet Removed ***

This will create a console window along with the win32 window(assuming you set up everything right with creating the win32 window). After that you can just use cout any where to print stuff to console window.

Or you could just use AllocConsole().
DesignerX
DesignerX
Thank you all for your replies !
There is nothing that can't be solved. Just people that can't solve it. :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.