example of printing coloured text in console box:
#include <windows.h>
void my_print(char* string,WORD color)
{
HANDLE hout;
CONSOLE_SCREEN_BUFFER_INFO csbi;
COORD point;
int nsize;
DWORD output;
point.X=0;
hout=GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hout,&csbi);
point.Y=csbi.dwSize.Y-2; /* or point.Y=23 */
nsize=lstrlen(string);
WriteFile(hout,string,nsize,&output,0);
FillConsoleOutputAttribute(hout,color,nsize,point,&output);
}
void main(void)
{
my_print("DO YOU LIKE GREEN?\x0a",FOREGROUND_GREEN);
my_print("DO YOU LIKE BLUE?\x0a",FOREGROUND_BLUE);
}
makefile:
POC_PROJECT_PATH = .
CC = pocc.exe
LINK = polink.exe
POC_INCLUDE =
CCFLAGS = -c -Ze -Zl -Tx86-coff -Ox -W1 -Gd -Ic:\progra~1\pellesc\include\ -Ic:\progra~1\pellesc\include\win
LINKFLAGS = /entry:main /nodefaultlib /merge:.data=.text /merge:.rdata=.text /machine:ix86 /subsystem:console kernel32.lib
"$(POC_PROJECT_PATH)\myprint.EXE": \
"$(POC_PROJECT_PATH)\myprint.OBJ"
$(LINK) $(LINKFLAGS) -out:"$@" $**
"$(POC_PROJECT_PATH)\myprint.OBJ": \
"$(POC_PROJECT_PATH)\myprint.c"
$(CC) $(CCFLAGS) "$!" -Fo"$@"
result: myprint.exe 1024 bytes