3 replies
There are many handles dealing with the "console window". The correct answer relates to what you want to do with the console window.
If you want to control the console (as a "window" then you'll need the handle received from the GetConsoleWindow() Win32 API function. This returns the console window's window handle. One caveat: this funiton is not defined in any of the Visual C++ headers. You'll have to prototype it yourself in order to use it, for example:
#include
HWND GetConsoleWindow(VOID);
void main(void){
HWND hwnd = ::GetConsoleWindow();
}
More info: http://msdn.microsoft.com/library/psdk/winbase/conchar_3eif.htm
If you're looking for one of the standard input/output handles and to output/input text to/from the console window you can do that with one of several handles. These handles can be retrieved with the function GetStdHandle(nStdHandle) with the following values for nStdHandle: STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, STD_ERROR_HANDLE. Redirection can be accomplished with the SetStdHandle() function. Check out http://msdn.microsoft.com/library/psdk/winbase/conchar_7k9x.htm and http://msdn.microsoft.com/library/psdk/winbase/conchar_7y79.htm
by pjrs
by pjrs
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending