diff --git a/VisualC/SDL/SDL_VS2012_WinRT.vcxproj b/VisualC/SDL/SDL_VS2012_WinRT.vcxproj
index aedcb381f..cddcbdff9 100644
--- a/VisualC/SDL/SDL_VS2012_WinRT.vcxproj
+++ b/VisualC/SDL/SDL_VS2012_WinRT.vcxproj
@@ -378,7 +378,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _WINDLL;__WINRT__=1;%(PreprocessorDefinitions)
+ _WINDLL;%(PreprocessorDefinitions)
Console
@@ -392,7 +392,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _WINDLL;__WINRT__=1;%(PreprocessorDefinitions)
+ _WINDLL;%(PreprocessorDefinitions)
Console
@@ -406,7 +406,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _WINDLL;__WINRT__=1;%(PreprocessorDefinitions)
+ _WINDLL;%(PreprocessorDefinitions)
Console
@@ -420,7 +420,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _WINDLL;__WINRT__=1;%(PreprocessorDefinitions)
+ _WINDLL;%(PreprocessorDefinitions)
Console
@@ -434,7 +434,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _WINDLL;__WINRT__=1;%(PreprocessorDefinitions)
+ _WINDLL;%(PreprocessorDefinitions)
Console
@@ -448,7 +448,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _WINDLL;__WINRT__=1;%(PreprocessorDefinitions)
+ _WINDLL;%(PreprocessorDefinitions)
Console
diff --git a/VisualC/tests/loopwave/WinRT/loopwave_VS2012_WinRT.vcxproj b/VisualC/tests/loopwave/WinRT/loopwave_VS2012_WinRT.vcxproj
index 852dbd32a..bb27ceb52 100644
--- a/VisualC/tests/loopwave/WinRT/loopwave_VS2012_WinRT.vcxproj
+++ b/VisualC/tests/loopwave/WinRT/loopwave_VS2012_WinRT.vcxproj
@@ -105,7 +105,7 @@
- NDEBUG;__WINRT__;%(PreprocessorDefinitions)
+ NDEBUG;%(PreprocessorDefinitions)
NotUsing
NotUsing
NotUsing
@@ -113,7 +113,7 @@
- _DEBUG;__WINRT__;%(PreprocessorDefinitions)
+ _DEBUG;%(PreprocessorDefinitions)
NotUsing
NotUsing
NotUsing
diff --git a/include/SDL_platform.h b/include/SDL_platform.h
index 569215c6d..2b2192ca8 100644
--- a/include/SDL_platform.h
+++ b/include/SDL_platform.h
@@ -114,12 +114,44 @@
#undef __SOLARIS__
#define __SOLARIS__ 1
#endif
+
#if defined(WIN32) || defined(_WIN32)
-#if ! defined(__WINRT__)
+/* Try to find out what version of Windows we are compiling for */
+#if defined(_MSC_VER) && (_MSC_VER >= 1700) /* _MSC_VER==1700 for MSVC 2012 */
+#include
+#endif
+/* Default to classic, Win32 / Desktop compilation if the version of Windows
+ cannot be determined via winapifamily.h. */
+#if ! defined(WINAPI_FAMILY_PARTITION)
+#undef __WIN32__
+#define __WIN32__ 1
+#else
+/* Include Win32 / Desktop App APIs in SDL, if available: */
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#undef __WIN32__
+#define __WIN32__ 1
+#endif
+/* Include WinRT / Windows Store APIs in SDL, if available: */
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+#undef __WINRT__
+#define __WINRT__ 1
+#endif
+#endif
+#endif
+
+/*
+#if ! defined(WINAPI_FAMILY_PARTITION) || ! WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#undef __WIN32__
#define __WIN32__ 1
+#error win32_defined
#endif
#endif
+#if defined(WINAPI_FAMILY_PARTITION) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+#undef __WINRT__
+#define __WINRT__ 1
+#error winrt_defined
+#endif
+*/
#if defined(__NDS__)
#undef __NINTENDODS__