示例#1
0
        public static void ClearConsole()
        {
            using (SafeHandle hConsoleOutput = ConsoleInterface.getConsoleOutputHandle())
            {
                // get dimensions of the screen buffer
                NativeInterface.CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo = ConsoleInterface.getScreenBufferInfo();

                int charsToWrite = screenBufferInfo.dwSize.X * screenBufferInfo.dwSize.Y;
                int charsWritten;
                ConsoleInterface.callWin32Func(() => NativeInterface.FillConsoleOutputCharacter(hConsoleOutput, ConsoleInterface.SPACE_CHAR, charsToWrite, default(NativeInterface.COORD), out charsWritten));
                ConsoleInterface.callWin32Func(() => NativeInterface.SetConsoleCursorPosition(hConsoleOutput, default(NativeInterface.COORD)));
            }
        }