首页 > 其他 > 详细

C 修改命令行文本颜色

时间:2014-07-30 11:59:33      阅读:372      评论:0      收藏:0      [点我收藏+]
#include <Windows.h>
#include <stdio.h>

int main()
{
    HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
    WORD wOldColorAttrs;
    CONSOLE_SCREEN_BUFFER_INFO csbiInfo;

    /*
    * First save the current color information
    */
    GetConsoleScreenBufferInfo(h, &csbiInfo);
    wOldColorAttrs = csbiInfo.wAttributes;

    /*
    * Set the new color information
    */
    SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_INTENSITY);

    printf("This is a test\n");
    /*
    * Restore the original colors
    */
    SetConsoleTextAttribute(h, wOldColorAttrs);
}

 

C 修改命令行文本颜色,布布扣,bubuko.com

C 修改命令行文本颜色

原文:http://www.cnblogs.com/emyueguang/p/3877307.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!