#include #include "../include/utils.h" #include "../include/constantes.h" using namespace std; FARPROC getConsoleFunction(char *name) { static HMODULE kernel32=(HMODULE)0xffffffff; if(kernel32==0) return NULL; if(kernel32==(HMODULE)0xffffffff) { kernel32=LoadLibrary("kernel32.dll"); if(kernel32==0) return 0; } return GetProcAddress(kernel32,name); } void printf_en_couleur(string texte, int couleur) { HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); // pointer to the SetConsoleTextAttribute() winapi function int (WINAPI* doSetConsoleTextAttribute)(HANDLE hConsoleOutput, WORD attr); doSetConsoleTextAttribute = (int (__attribute__((__stdcall__)) *)(void*, short unsigned int)) getConsoleFunction("SetConsoleTextAttribute"); int couleurWindows; switch (couleur) { case C_VERT: couleurWindows = 10; break; case C_BLEU: couleurWindows = 9; break; case C_VIOLET: couleurWindows = 13; break; case C_JAUNE: couleurWindows = 14; break; case C_ROUGE: couleurWindows = 12; break; case C_MULTI: couleurWindows = 7*16; break; } (*doSetConsoleTextAttribute)(hCon, couleurWindows); cout << texte; (*doSetConsoleTextAttribute)(hCon, 7); }