Author: hi.baidu.com/console_app
Test environment: VC++ 6.0
The font size of the console can be changed. The system provides us with many APIs, and the API that can change the font size is hidden in it. There is no information about host font size on the internet, and the tutorial on host font size is published exclusively by this blog. This article will teach you how to use these APIs to modify the font size of the console.
Usually, each output buffer in the console has a fixed font. Each font in the system has a corresponding serial number, and each font has a different font size. If you want to change it to a new font, you can assign the serial number of the font to the console buffer. Generally speaking, the total number of all fonts in the system does not exceed 40, so this can be used as the upper limit when obtaining information circularly.
First, publish a list of APIs to use:
(Most of the following APIs have not been made public, and the details of several of them have only been made public recently. )
Boolsetconsolefont (handle, dword)// Note that once this function is called, the font size of all characters will change and the window size will also change. This is used to set the font size. The first parameter is the output handle, and the second parameter is the new font size serial number.
Boolgetconsolefontinfo (handle, bool, dword, CONSOLE_FONT *) is used to obtain font information. The first parameter is the output handle, the second parameter should be set to 0, the third parameter is the font number of the obtained information, and the fourth parameter is a pointer to the console _ font structure, and the API will put the returned information in this structure.
COORD getconsolefontsize (handle, dword) is used to get the font size. The first parameter is the output handle, the second parameter is the font number of the size, and the two members of the returned coord are the font size.
The DWORD GetNumberOfConsoleFonts () function is used to get the number of available fonts and return the total number of available fonts.
BoolgetCurrentConsolefont (handle, bool, CONSOLE_FONT *) is used to get the information of the current font. The first parameter is the output handle, the second parameter should be set to 0, and the third parameter is a pointer to the console _ font structure, in which the API will put the returned information.
Structure console _FONT:
Struct CONSOLE _ FONT {DWORD index coordinate size; };
The first member is the serial number of the font, and the second member is the font size.
Due to space, each API function is not discussed one by one. For the corresponding meaning of its parameter types, please refer to other articles.
First of all, these are unpublished APIs that need to be loaded dynamically. First, declare them globally:
Struct CONSOLE _ FONT {DWORD index coordinate size; }; typedef BOOL(WINAPI * PROCSETCONSOLEFONT)(HANDLE,DWORD); typedef BOOL(WINAPI * PROCGETCONSOLEFONTINFO)(HANDLE,BOOL,DWORD,CONSOLE _ FONT *); typedef COORD(WINAPI * PROCGETCONSOLEFONTSIZE)(HANDLE,DWORD); typedef DWORD(WINAPI * PROCGETNUMBEROFCONSOLEFONTS)(); typedef BOOL(WINAPI * PROCGETCURRENTCONSOLEFONT)(HANDLE,BOOL,CONSOLE _ FONT *); PROCSETCONSOLEFONT SetConsoleFont; PROCGETCONSOLEFONTINFO GetConsoleFontInfo; PROCGETCONSOLEFONTSIZE GetConsoleFontSize; PROCGETNUMBEROFCONSOLEFONTS GetNumberOfConsoleFonts; PROCGETCURRENTCONSOLEFONT
Then load it when the program starts:
h module hkernel 32 = GetModuleHandle(" kernel 32 "); SetConsoleFont =(PROCSETCONSOLEFONT)GetProcAddress(hkernel 32," SetConsoleFont "); GetConsoleFontInfo =(proctgetconsolefontinfo)GetProcAddress(hkernel 32," GetConsoleFontInfo "); GetConsoleFontSize =(PROCGETCONSOLEFONTSIZE)GetProcAddress(hkernel 32," GetConsoleFontSize "); GetNumberOfConsoleFonts =(PROCGETNUMBEROFCONSOLEFONTS)GetProcAddress(hkernel 32," GetNumberOfConsoleFonts "); GetCurrentConsoleFont =(PROCGETCURRENTCONSOLEFONT)GetProcAddress(hkernel 32," GetCurrentConsoleFont ");
After loading, the font size can be controlled by programming.
The hardest part of the body is the leg. It takes a long time to lose weight if you want to lose weight. Here, I will share with you some stovepipe exercise