GetCurrentConsoleFontEx: What am I doing wrong? NVM, found it.

  • Thread starter Thread starter Dean Sands
  • Start date Start date
D

Dean Sands

Guest
Couldn't figure out why this code wasn't working. The documentation didn't mention that I needed to set the cbSize property. I remember seeing it needed on another function, and I'm guessing that's common practice in the Windows API.

#include <Windows.h>
#include <iostream>
int main()
{
CONSOLE_FONT_INFOEX cfo;
cfo.cbSize = sizeof(CONSOLE_FONT_INFOEX); //Forgot this line. Here's the bug.
if(!::GetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfo)) {
std::wcout << GetLastError() << std::endl;
return -1;
}
std::wcout << cfo.FaceName << std::endl;
return 0;
}

Continue reading...
 
Back
Top