簡體   English   中英

Windows API將輸出顏色輸出到Powershell / cmd.exe中的stdout

[英]Windows API colored output to stdout in Powershell/cmd.exe

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

Win32 控制台API有一個函數SetConsoleTextAttribute ,可用於設置文本前景色和背景色。 示例代碼在這里

至少有顏色命令:

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

給出帶有黑色文字的銀色背景。

不完全是參考,但它應該可以幫助您找到您在MSDN上尋找的內容,請查看:

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

您可能想要查找“WriteConsoleOutput”。

在powershell中,write-host采用-backgroundcolor和-foregroundcolor參數

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM