Windows API将输出颜色输出到Powershell / cmd.exe中的stdout

时间:2008-10-30 20:25:40

标签: windows colors stdout command-line-interface

任何人都知道在哪里可以找到描述如何使用API​​和/或stdout在Windows CLI界面上输出颜色的参考?

4 个答案:

答案 0 :(得分:3)

Win32 console API有一个函数SetConsoleTextAttribute,可用于设置文本前景色和背景色。示例代码为here

答案 1 :(得分:1)

至少有颜色命令:

color bg fg

其中:

0: Black
1: Blue
2: Green
3: Cyan
4: Red
5: Purple
6: Yellow
7: Gray
8: Silver
9: Light blue
A: Lime
B: Light cyan
C: Light red
D: Light purple
E: Light yellow
F: White

示例:

color 80

带有黑色文字的银色背景。

答案 2 :(得分:1)

不完全是参考,但它可以帮助您找到您在MSDN上寻找的内容,请查看:

http://www.gamedev.net/community/forums/topic.asp?topic_id=457528

您可能想要查找“WriteConsoleOutput”。

答案 3 :(得分:0)

PowerShell中的

写主机采用-backgroundcolor和-foregroundcolor参数

相关问题