I compiled this code without any errors and warnings with GCC mingw32:
#define WINVER 0x0500
#include <windows.h>
HWND StdHandle = GetStdHandle (STD_OUTPUT_HANDLE);
CONSOLE_FONT_INFO GETFONT;
GetCurrentConsoleFont (StdHandle, FALSE, &GETFONT);
if (GETFONT.dwFontSize.X != 8 || GETFONT.dwFontSize.Y != 12)
printf ("Font-Size is not 8 x 12");
else
printf("Font-Size is 8 x 12");
It runs perfectly in Windows 7.
But, when it runs in Windows XP and I adjust the console font-size to "8 x 12", GETFONT.dwFontSize.X
always equals 80, and GETFONT.dwFontSize.Y
always equals 25.
Then, I added
DWORD ErrorCode = GetLastError();
And, it returns 0x0
(ERROR_SUCCESS(:The operation completed successfully.))
Why it always get the wrong value when using GetCurrentConsoleFont in Windows XP?
BOOL WINAPI GetCurrentConsoleFont (HANDLE hConsoleOutput, BOOL bMaximumWindow, PCONSOLE_FONT_INFO lpConsoleCurrentFont);
COORD WINAPI GetConsoleFontSize (HANDLE hConsoleOutput, DWORD nFont);
CONSOLE_FONT_INFO GETFONT;
GetCurrentConsoleFont (StdHandle, FALSE, &GETFONT);
COORD Fontsize = GetConsoleFontSize (StdHandle, GETFONT.nFont);
SHORT Font_X = Fontsize.X;
SHORT Font_Y = Fontsize.Y;
if (Font_X != 8 || Font_Y != 12)
{
printf ("Font-Size is not 8 x 12");
}