我想要全屏控制台,就像按 Alt + Enter 一样。唯一有点接近我想要的东西就像this一样,除了它最大化它,而不是全屏。
那个代码看起来怎么样?
答案 0 :(得分:3)
创建一个控制台应用程序并使用以下代码: Source以及我的一些修复(在Windows 10上测试):
using System;
using System.Runtime.InteropServices;
namespace Test
{
internal class Program
{
[DllImport("kernel32.dll")]
private static extern IntPtr GetStdHandle(int handle);
private static void Main(string[] args)
{
IntPtr hConsole = GetStdHandle(-11);
SetConsoleDisplayMode(hConsole, 1, out COORD b1);
Console.ReadLine();
}
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool SetConsoleDisplayMode(IntPtr ConsoleOutput, uint Flags, out COORD NewScreenBufferDimensions);
[StructLayout(LayoutKind.Sequential)]
public struct COORD
{
public short X;
public short Y;
public COORD(short X, short Y)
{
this.X = X;
this.Y = Y;
}
}
}
}