C#全屏控制台?

我已经看到Windows在更新video驱动程序时可以切换到非常基本的控制台界面,我也看到像Borland C ++这样的程序。
我真的很想知道如何使用C#中的控制台应用程序(或者如果你愿意的话,还可以使用VB.NET),我不介意使用P / Invoke(我打赌我必须!)。

在旧版本的Windows中,您可以使用Alt-Enter将任何控制台全屏显示(如果我没记错的话)。

随着桌面窗口管理器的引入和Vista中GPU的全屏组合,全屏控制台窗口function被删除。

(更新图形驱动程序时,图形子系统正在重置,您看到的不是控制台窗口,而是图形卡默认启动到文本模式。)

Windows 7不支持全屏控制台应用程序。 在XP上你可以使用SetConsoleDisplayMode ,你需要P / Invoke到这个,但它相对简单。 我知道在win 7 x64上此function将失败并显示错误120 This function is not spported on this system

要获得控制台句柄,您可以使用此答案中的一些代码。

您可以右键单击控制台,单击属性,然后在选项盘中将其设置为全屏。 您可以保存此更改以保持持久性。

你的意思是完全卸载GUI,或者更改屏幕分辨率,比如当你安装新的设备驱动程序并且windows变为800×600 / 8bpp时,而不是你的正常分辨率? 如果你想要一个全屏控制台我不能帮忙,但如果你想改变你的屏幕分辨率等,请看看http://www.c-sharpcorner.com/UploadFile/GemingLeader/display-settings08262009094802AM/display- settings.aspx

也许我的实施可能有所帮助。 请注意,这不适用于缺少文本模式驱动程序支持的Windows系统。

 using System; using System.IO; using System.Collections.Generic; //for dictionary using System.Runtime.InteropServices; //for P/Invoke DLLImport class App { ///  /// Contains native methods imported as unmanaged code. ///  internal static class DllImports { [StructLayout(LayoutKind.Sequential)] public struct COORD { public short X; public short Y; public COORD(short x, short y) { this.X = x; this.Y = y; } } [DllImport("kernel32.dll")] public static extern IntPtr GetStdHandle(int handle); [DllImport("kernel32.dll", SetLastError = true)] public static extern bool SetConsoleDisplayMode( IntPtr ConsoleOutput ,uint Flags ,out COORD NewScreenBufferDimensions ); } /// Main App's Entry point public static void Main (string[] args) { IntPtr hConsole = DllImports.GetStdHandle(-11); // get console handle DllImports.COORD xy = new DllImports.COORD(100,100); DllImports.SetConsoleDisplayMode(hConsole, 1, out xy); // set the console to fullscreen //SetConsoleDisplayMode(hConsole, 2); // set the console to windowed } }