c++运行窗口全屏代码
#include <bits/stdc++.h>
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <iostream>
#include <conio.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll N=1e5+1e4;
COORD get_font_size()
{
COORD font_size;
HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);
struct CONSOLE_FONT{
DWORD index;
COORD dim;
}cfi;
typedef COORD (WINAPI *PROCGETCONSOLEFONTSIZE)(HANDLE, DWORD);
typedef BOOL (WINAPI *PROCGETCURRENTCONSOLEFONT)(HANDLE, BOOL, struct CONSOLE_FONT*);
HMODULE hKernel32=GetModuleHandle("kernel32");
PROCGETCONSOLEFONTSIZE GetConsoleFontSize=(PROCGETCONSOLEFONTSIZE)GetProcAddress(hKernel32,"GetConsoleFontSize");
PROCGETCURRENTCONSOLEFONT GetCurrentConsoleFont=(PROCGETCURRENTCONSOLEFONT)GetProcAddress(hKernel32,"GetCurrentConsoleFont");
GetCurrentConsoleFont(handle, FALSE, &cfi);
font_size=GetConsoleFontSize(handle, cfi.index);
return font_size;
}
//______________________________
void full_screen()
{
HWND hwnd=GetForegroundWindow();
HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE); /* 标准输出缓冲区句柄 */
int cx=GetSystemMetrics(SM_CXSCREEN); /* 屏幕宽度 */
int cy=GetSystemMetrics(SM_CYSCREEN); /* 屏幕高度 */
COORD size=get_font_size();
char cmd[32]={0};
sprintf(cmd, "MODE CON: COLS=%d LINES=%d", cx / size.X, cy / size.Y);
system(cmd);
SetWindowPos(hwnd, HWND_TOP, 0, .0, cx, cy, 0);
}
signed main()
{
full_screen();
return 0;
}