Created
September 12, 2019 07:55
-
-
Save matarillo/ee65dba587f093dc20ad8e1782673140 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
namespace mattn | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
IntPtr h = NativeMethods.GetStdHandle(STD_OUTPUT_HANDLE); | |
COORD coord = new COORD(80, 31); | |
bool b = NativeMethods.SetConsoleScreenBufferSize(h, coord); | |
Console.WriteLine(b); | |
} | |
internal const int STD_OUTPUT_HANDLE = -11; | |
internal static class NativeMethods | |
{ | |
[DllImport("kernel32.dll", SetLastError = true)] | |
internal static extern IntPtr GetStdHandle(int nStdHandle); | |
[DllImport("kernel32.dll", SetLastError = true)] | |
internal static extern bool SetConsoleScreenBufferSize(IntPtr hConsoleOutput, COORD size); | |
} | |
internal struct COORD | |
{ | |
internal short X; | |
internal short Y; | |
internal COORD(short x, short y) | |
{ | |
this.X = x; | |
this.Y = y; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment