Article ID: 104094
Article Last Modified on 8/9/2005
/* Compile options needed: None
*/
#include <windows.h>
#include <stdio.h>
int main( void )
{
HANDLE hConsole;
WORD ForeColor = 0;
WORD BackColor;
WORD wAttributesOld;
CONSOLE_SCREEN_BUFFER_INFO csbi;
// ** Open the current console input buffer.
if( ( hConsole = CreateFile(
"CONOUT$", GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
0L, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0L) )
== (HANDLE) -1 ) {
printf("\nError: Unable to open console.\n");
return( -1 );
}
printf("\n");
// ** Get and Save information on the console screen buffer.
GetConsoleScreenBufferInfo( hConsole, &csbi );
wAttributesOld = csbi.wAttributes;
// ** Display different backgrounds.
for( BackColor = 0; BackColor < 8 ; BackColor++ ) {
SetConsoleTextAttribute( hConsole, (WORD) ( (BackColor << 4) |
ForeColor) );
printf(" XxXxXx ");
}
// ** Restore the foreground and background color attribute.
SetConsoleTextAttribute( hConsole, wAttributesOld );
return 1;
}
Additional query words: 8.00 9.00
Keywords: kbinfo kbarttypeinf KB104094