I\'m working on a test script for Windows Tablets, Windows Phones and Windows Store apps. The scripts are mostly working for under Visual Studio 2012 and Windows Kit 8.0 SDK. It
If you look in "C:\Program Files (x86)\Windows Kits\8.1\Include\shared\winapifamily.h" on line 115, you'll see that the WINAPI_FAMILY
value has to be one of WINAPI_FAMILY_DESKTOP_APP
, WINAPI_FAMILY_PC_APP
, or WINAPI_FAMILY_PHONE_APP
(Windows 10 adds WINAPI_FAMILY_SYSTEM
and WINAPI_FAMILY_SERVER
to the mix). This implies that your command-line flag /DWINAPI_FAMILY=WINAPI_PARTITION_DESKTOP
should instead be /DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP
when you build for Windows 8.1 or 10. However, if you leave it out, you'll get the default you want - see line 57 in the Windows 8.1 SDK version of winapifamily.h.
After the check, the next thing the header does is define the WINAPI_PARTITION_*
values based on which WINAPI_FAMILY
values are set. Notice that they are all either 1 or 0, where in Windows 8.0, the WINAPI_PARTITION_APP
value was always 0x00000002. Conceivably, you could test whether WINAPI_PARTITION_APP
is set to 1 instead of 0x00000002 to determine if the SDK in use was building an 8.1 app instead of an 8.0 app:
#if defined(WINAPI_PARTITION_APP)
#if (WINAPI_PARTITION_APP == 0x00000002)
#define USING_WINDOWS_8_0_SDK
#endif
#if defined(WINAPI_FAMILY_SYSTEM)
#define USING_WINDOWS_10_SDK
#else
#if (WINAPI_PARTITION_APP == 1)
#define USING_WINDOWS_8_1_SDK
#endif
#endif
#endif
I haven't actually tried this, since I haven't needed to switch within my code based on which SDK is in use.