I'm new to C and making a console application where I need to change the default 16-color palette of the Windows console. I found out through this question that I need to use the SetConsoleScreenBufferInfoEx()
function, however, my compiler insists that no such function is declared (I've only included windows.h
).
Also, it doesn't recongnise the CONSOLE_SCREEN_BUFFER_INFOEX
structure that is needed for the function to work and only recognises CONSOLE_SCREEN_BUFFER_INFO
.
I've been searching for a solution for this for days and the closest thing I found was an answer here saying that I need to specify in my code that I'm targeting versions of Windows that are Vista or later. So I've tried defining
#define NTDDI_VERSION NTDDI_VISTA
and #define _WIN32_WINNT _WIN32_WINNT_VISTA
, but that didn't work either.
Remember that I'm new to C, so please try to make any answers and explanations as simple as possible (I'm using Code::Blocks and Windows 10).
EDIT: I did a lot of searching around and here's what I found to help save some time for anyone that might have the same problem (a lot of the information below could be wrong so be warned and feel free to correct it if that's indeed the case):
SetConsoleScreenBufferInfoEx
is a function that's only included in theConsoleApi2.h
header (used bywindows.h
) from the Windows SDK and as such, needs the SDK in order to work.The MinGW compiler doesn't work well (if at all) with the SDK. It uses its own implementation of
windows.h
with only partial support for the SDK functions.It is possible to use the VC++ compiler with Code::Blocks, in order to access the SDK functions. (however, I couldn't get it to work, so I just installed Visual Studio intead).