Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用 WinAPI 的 AllocConsole 函数将控制台附加到我的 winforms:
Declare Function AllocConsole Lib "kernel32.dll" () As Boolean
我想改变那个窗口的大小,但似乎我不能,我试过这个:
Console.writeline("mode con cols=150 lines=60")
我会使用 .NET 控制台功能Console.SetWindowSize()。请记住,如果您提供的尺寸太大(基于字体大小和屏幕分辨率),此函数会引发异常,因此请务必在调用该函数之前进行检查。
Console.SetWindowSize()
Console.SetWindowSize( Math.Min(150, Console.LargestWindowWidth), Math.Min(60, Console.LargestWindowHeight));