private static IntPtr CreateBuffer() { var buffer = NativeConsole.CreateConsoleScreenBuffer( NativeConsole.GENERIC_READ | NativeConsole.GENERIC_WRITE, 1, IntPtr.Zero, NativeConsole.CONSOLE_TEXTMODE_BUFFER, IntPtr.Zero); NativeConsole.CONSOLE_SCREEN_BUFFER_INFO_EX info = NativeConsole.CONSOLE_SCREEN_BUFFER_INFO_EX.Create(); // info.cbSize = sizeof(NativeConsole.CONSOLE_SCREEN_BUFFER_INFO_EX); NativeConsole.GetConsoleScreenBufferInfoEx(defaultHandle, ref info); info.dwSize = bufferSize; NativeConsole.SetConsoleScreenBufferInfoEx(buffer, info); //NativeConsole.SetConsoleScreenBufferSize(buffer, new NativeConsole.COORD(80, 40)); return(buffer); }