How to detect whether or not the current window is console window.
C / C++ / MFC
2
Posts
2
Posters
1
Views
1
Watching
-
Anyone knows how to detect whether or not the current window is console window. Thanx in advance...
-
Anyone knows how to detect whether or not the current window is console window. Thanx in advance...
HWND hwnd = ::GetForegroundWindow(); // if by "current window" you mean the foreground window
ASSERT(hwnd != NULL);
TCHAR szClass[256] = _T("");
::GetClassName(hwnd, szClass, 255);
if (_tcsicmp(szClass, _T("ConsoleWindowClass")) == 0)
{
// This is a console window
}
else
{
// This is not a console window
}I did not compile above code, but you should have got the main idea.