Setcolor was entirely programmed by Mahen of Mauritius. Who have never wished of changing the Font colors of the Command Prompt on the fly. Well this is where Setcolor comes in handy. The main function of this program is to change the default Font color of your Command Prompt. The colors start from 0 up to 9999. The following gives an example of the program's usage:

C:WINDOWS>setcolor 12

C:WINDOWS>setcolor -help

Usage: Setcolor -Help Displays this Message
-Default Returns the Font back to normal
"number" Changes the color of the Font according to number

NOTICE: You must not claim this program as yours!!!!

//   Title:  Setcolor

//   File:   Setcolor.exe

//   Description:  A program to change the font color of command prompt.

//   Author:  Mahen

//   Developped:   Pentium 3 733 Mhz, 192MB Ram, Windows XP Pro

//   Target:   Platform Independent

//   Revision History:   Completed in 1 day.

// Comment: You have the right to modify the Source Code as you wish, but you must not claim this Original Source as yours.


#include <string.h>
#include <stdio.h>
#include <iostream.h>
#include <windows.h>

/*Setcolor accepts a user input number from 0 - infinite and change the font color of the command prompt
  by exiting the command prompt, the font color returns to normal*/
int main(int argc, char* argv[])
        //We start by initializing the necessary API
        int color;
        color = atoi(argv[1]);
        HANDLE console;
        console = GetStdHandle(STD_OUTPUT_HANDLE);

        // We first check to make sure that the user gave a command
        if (argc == 2)

            //If the user enters help, a demonstration of all the colours will be shown
            if (strcmp(argv[1], "-help") == 0 || strcmp(argv[1], "-Help") == 0 || strcmp(argv[1], "-HELP") == 0)
              for(color = 0; color < 99999999; color++)
                 printf(" Usage: Setcolor -Help  Displays this Message\n"
                        "                 -Default Returns the Font back to normal\n"
                        "                 \"number\" Changes the color of the Font according to number\n");
                 SetConsoleTextAttribute(console, color);
                 cout << color << " This is the Help\n\n";
            //If the user wants to return back to normal colors without exiting the command prompt
            else if (strcmp(argv[1], "-default") == 0 || strcmp(argv[1], "-Default") == 0 || strcmp(argv[1], "-DEFAULT") == 0)
             SetConsoleTextAttribute(console, 15);
            //If the user gave a number, then that number is compared to see what color it matches
            else if (color <= 99999999)
                SetConsoleTextAttribute(console, color);
            //If a wrong command has been entered,  an error message is displayed
            //  and a demonstration of  all the colors is shown
              SetConsoleTextAttribute(console, 12);
              cout << "\n\nWrong Command!!!\n\n";
              goto LABEL;
        //In case no command has been entered, 
          cout << "Please enter the correct Command!!!!";

        return 0;

12 Years
Discussion Span
Last Post by berkcan

This is a nice lil' app but it is not OS independent as described, Please see source code line #3:

#include <windows.h>

Berk C. Celebisoy

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.