This topic is now archived and is closed to further replies.

console window HWND ?

This topic is 5622 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


how can i get the hWnd of a console window ? (if my app is a console app).

If you set a (unique) console title, SetConsoleTitle(..), you should be able to use:

HWND FindWindow(
LPCTSTR lpClassName, // class name
LPCTSTR lpWindowName // window name


i''d also like to know, if/how i can create a console window from within a pure win32 app.

All you need to do is to call AllocConsole(). If you want to be able to use cout/cin etc, you need to reopen the standard I/O handles:

freopen("CONIN$", "rb", stdin);
freopen("CONOUT$", "wb", stdout);
freopen("CONOUT$", "wb", stderr);

Regards Mats

Share this post

Link to post
Share on other sites
A console program is a pure Win32 app.

"The churches used to win their arguments against atheism, agnosticism, and other burning issues by burning the ismists, which is fine proof that there is a devil but hardly evidence that there is a God."
Ben Lindsey and Wainwright Evans

Share this post

Link to post
Share on other sites