MSDN 控制台输入输出及属性设置
来源:互联网 发布:淘宝网斯凯奇女鞋 编辑:程序博客网 时间:2024/06/02 04:54
#include <windows.h> #include <stdio.h> int main(void) { HANDLE hStdout;HANDLE hNewScreenBuffer; SMALL_RECT srctReadRect; SMALL_RECT srctWriteRect; CHAR_INFO chiBuffer[160]; // [2][80]; COORD coordBufSize; COORD coordBufCoord; BOOL fSuccess; // 获取一个用于拷贝的标准屏幕输出句柄 Get a handle to the STDOUT screen buffer to copy from and // 创建一个新的屏幕缓冲用于拷贝 create a new screen buffer to copy to. hStdout = GetStdHandle(STD_OUTPUT_HANDLE); hNewScreenBuffer = CreateConsoleScreenBuffer( GENERIC_READ | // read/write access GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, // shared NULL, // default security attributes CONSOLE_TEXTMODE_BUFFER, // must be TEXTMODE NULL); // reserved; must be NULL if (hStdout == INVALID_HANDLE_VALUE || hNewScreenBuffer == INVALID_HANDLE_VALUE) { printf("CreateConsoleScreenBuffer failed - (%d)\n", GetLastError()); return 1; }else{printf("CreateConsoleScreenBuffer successfully - (%d)\n", GetLastError()); } // Make the new screen buffer the active screen buffer. if (! SetConsoleActiveScreenBuffer(hNewScreenBuffer) ) { printf("SetConsoleActiveScreenBuffer failed - (%d)\n", GetLastError()); return 1; }else{printf("SetConsoleActiveScreenBuffer successfully - (%d)\n", GetLastError()); } // Set the source rectangle. srctReadRect.Top = 0; // top left: row 0, col 0 srctReadRect.Left = 0; srctReadRect.Bottom = 1; // bot. right: row 1, col 79 srctReadRect.Right = 79; // The temporary buffer size is 2 rows x 80 columns. coordBufSize.Y = 2; coordBufSize.X = 80; // The top left destination cell of the temporary buffer is // row 0, col 0. coordBufCoord.X = 0; coordBufCoord.Y = 0; // Copy the block from the screen buffer to the temp. buffer. fSuccess = ReadConsoleOutput( hStdout, // screen buffer to read from chiBuffer, // buffer to copy into coordBufSize, // col-row size of chiBuffer coordBufCoord, // top left dest. cell in chiBuffer &srctReadRect); // screen buffer source rectangle if (! fSuccess) { printf("ReadConsoleOutput failed - (%d)\n", GetLastError()); return 1; }else{printf("ReadConsoleOutput successfully - (%d)\n", GetLastError());} // Set the destination rectangle. srctWriteRect.Top = 10; // top lt: row 10, col 0 srctWriteRect.Left = 0; srctWriteRect.Bottom = 11; // bot. rt: row 11, col 79 srctWriteRect.Right = 79; // Copy from the temporary buffer to the new screen buffer. fSuccess = WriteConsoleOutput( hNewScreenBuffer, // screen buffer to write to chiBuffer, // buffer to copy from coordBufSize, // col-row size of chiBuffer coordBufCoord, // top left src cell in chiBuffer &srctWriteRect); // dest. screen buffer rectangle if (! fSuccess) { printf("WriteConsoleOutput failed - (%d)\n", GetLastError()); return 1; }else{printf("WriteConsoleOutput successfully - (%d)\n", GetLastError()); } Sleep(5000); // Restore the original active screen buffer. if (! SetConsoleActiveScreenBuffer(hStdout)) { printf("SetConsoleActiveScreenBuffer failed - (%d)\n", GetLastError()); return 1; }else{printf("SetConsoleActiveScreenBuffer successfully - (%d)\n", GetLastError()); } return 0;}
- MSDN 控制台输入输出及属性设置
- MSDN 控制台输入输出及属性设置
- 文件操作及控制台输入输出
- 控制台输入输出
- 控制台输入输出数据
- 读取控制台输入输出流
- 控制台输入输出重定向
- 控制台的输入输出
- MASM32 控制台输入输出
- java控制台输入输出字符串
- java控制台输入输出字符串
- 控制台文件的输入输出
- QT控制台输入输出QString
- Java 控制台输入输出
- 格式化文件/控制台输入输出
- java控制台的输入输出
- Swift3.0 控制台输入输出
- Qt控制台输入输出
- 重新开始写blog
- COM, OLE技术概述
- 键盘扫描码
- 求一般矩阵的逆矩阵C++代码
- 轻松掌握Windows窗体间的数据交互
- MSDN 控制台输入输出及属性设置
- [不好意思,你是那37%的人]
- .NET GUI+ 为图片生成圆角
- HDU 1874 畅通工程续
- FCKeditor分页符的应用
- 二进制数转十进制数函数
- Ubuntu下的Android(二)、搭建jdk环境
- Mongodb操作详解 续
- 【转载】[常识]主流浏览器内核概览