Have a look at the NTDDI_VERSION
macro.
#if NTDDI_VERSION == 0x06030000 // NTDDI_WINBLUE
/* Windows 8.1 */
#elif NTDDI_VERSION == 0x06020000 // NTDDI_WIN8
/* Windows 8 */
#endif
Make sure you've included SdkDdkVer.h
, but it I believe most Windows projects already do that by default.