public void ClearScreen() { const int STD_OUTPUT_HANDLE = -11; int hConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE); int hWrittenChars = 0; CONSOLEBUFFER strConsoleInfo = new CONSOLEBUFFER(); POSITION pos; pos.x = pos.y = 0; GetConsoleScreenBufferInfo(hConsoleHandle, ref strConsoleInfo); FillConsoleOutputCharacter(hConsoleHandle, 32, strConsoleInfo.size.x * strConsoleInfo.size.y, pos, ref hWrittenChars); SetConsoleCursorPosition(hConsoleHandle, pos); }
private static extern int GetConsoleScreenBufferInfo(int handleConsoleOutput, ref CONSOLEBUFFER bufferinfo);