• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2517
  • Last Modified:

How can I print color text under "cmd.exe" in windows XP

I've tried putting ansi.sys into config.nt, but later discovered that this is not relevant to "cmd.exe" (and obviously, ansi escape sequences don't just work without something to handle them).

I've tried writing a driver to call int 10h, but this blows up on the int 10h call with the following error:-
    Unhandled exception ...: 0xC0000005: Access Violation.

I don't recall an INT21 interface for changing color. I can't find any hints in MSVC++ help, nor google.

I know cmd.exe can *do* color, since after dropping into NTVDM and doing color there, it returns and retains the color on the cmd.exe's screen (and the cmd.exe's output overwrites both the residual outputted text as well as the color attributes, so whatever output routine cmd.exe is using, it's programmed to *do* colour it seems; and of course you can set everything to colors other than black+white (see cmd.exe /?)... it's just not clear how to have colored output!)
1 Solution
ChrisDrakeAuthor Commented:
Awesome!  I *can't* beleive how long I spent both in Google *and* MSDN trying to hunt this down... It was of course there all the time; but as with almost all Microsoft technologies, if you don't know the obscure words/phrases MS have dreamed up for the concept (in this case - it was "SetConsoleTextAttribute()" ), you've got no chance of hunting it down.

Anyways - I wrote me my own shiny new ANSI to SetConsoleTextAttribute() converting driver, and I'm happy-as now :-)

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now