How to get the OS Version (8.1 or 10) for a WinRT app ? RRS feed

  • General discussion

  • I have a Windows Store App for Windows 8.1 and run on Windows 10 as well.

    I need to detect if is running on 8.1 or 10 to change the UI.

    What API can I use to detect the main version of the OS?

    PS: do not suggest to port the app to UWP

    Thank you

    Monday, September 14, 2015 5:17 PM

All replies

  • In short: You can't detect running on Windows 10 vs. Windows 8.1 in a Windows 8.1 Store app.

    Windows 8 Store apps and Windows phone 8 apps by design cannot get the OS version number as this is a long-standing source of appcompat bugs for desktop apps. There is a rather dodgy hack I've heard some developers make use of to detect the OS version in Windows 8 Store apps, but doing so is likely to in fact cause appcompat bugs in future. Most OS version checks are done incorrectly or are used as proxies for more accurate and supportable ways to detect a particular feature.

    For Windows 10 UWP apps, you still by design can't call GetVersion or some equivalent, although there is a new WinRT API intended explicitly for use in telemetry & diagnostic logs only, and not for doing OS-version dependent version checks in your app. Windows 8 Store apps running on Windows 10 can't use the newer API in any case.

    BTW, even for Windows desktop apps, OS version checks are strongly discouraged. GetVersionEx was 'deprecated' for Windows 8.1, and VerifyVersionInfo is also 'deprecated' in the same way for Windows 10. See this blog post for how this changes the behavior of these Windows desktop APIs.

    Monday, September 14, 2015 7:50 PM