i've tryed
system("color a");
and i've changed my consle text color to green, now i wanna to get the console color
is there anyway to do it ?
don't say try
char col[256]; strcpy(col, "a");
i need a function like "system("getcolor");" for example




Posted 31 August 2009 - 05:55 AM
system("color a");
char col[256]; strcpy(col, "a");
Posted 31 August 2009 - 06:46 AM
#include <iostream>
const int Colours = system("color 2A");
int main()
{
return 0;
}
Posted 31 August 2009 - 07:05 AM
stev3, on 31 Aug, 2009 - 05:46 AM, said:
#include <iostream>
const int Colours = system("color 2A");
int main()
{
return 0;
}
Posted 31 August 2009 - 07:17 AM
#include <windows.h>
#include <stdio.h>
int GetColor(void);
int getForground(void);
int getBackground(void);
int main()
{
int forg, back;
system("Color 17");
forg = getForground();
back = getBackground();
printf("forground color: %d\nBackground color: %d\n", forg, back);
return 0;
}
//This will set the forground color for printing in a console window.
int GetColor()
{
WORD wColor = 0;
//We will need this handle to get the current background attribute
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
//We use csbi for the wAttributes word.
if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
{
//return the wAttributes data
wColor = (csbi.wAttributes & 0xFF);
}
return wColor;
}
int getForground()
{
//Mask out all but the lower nibble
return GetColor() & 0x0F;
}
int getBackground()
{
// Shift down one nibble (4bits) and then mask off everything else
return (GetColor() >> 4) & 0x0F;
}
Posted 31 August 2009 - 07:30 AM
Posted 31 August 2009 - 07:43 AM
Posted 31 August 2009 - 08:09 AM
NickDMax, on 31 Aug, 2009 - 06:43 AM, said:
