GGleGrand
GGleGrand

Reputation: 1650

How to get the installed OS version number in C#

Still looking for a way to simply get the current OS version (e.g. OS Version:10.0.14393.0) from a C#/UWP iot-core app. Pointers? If I search the web, I get jumbles of confusing hacks.

The version number for iot-core being very significant, we find statements like this all over the place "This branch supports the lastest windows IoTCore release available ( currently 1607, version number 10.0.14393.x )" And windows 10 UWP devices now do automatic OS updates. So how do I get this information from the device (iot-core/UWP) at runtime?

Note: "Environment.OSVersion.Version" is apparently not available so this is not a duplicate to post How to get OS version number?

Upvotes: 1

Views: 1856

Answers (1)

Jay Zuo
Jay Zuo

Reputation: 15758

According to your description, I think what you actually need is ApiInformation class. This class enables you to detect whether a specified member, type, or API contract is present so that you can safely make API calls across a variety of devices. So we do not need to get the current OS version to see if something is supported in the device. The key point here is Detect features, not OS or devices.

The fundamental idea behind adaptive apps is that your app checks for the functionality (or feature) it needs, and only uses it when available. The traditional way of doing this is by checking the OS version and then use those API. With Windows 10, your app can check at runtime, whether a class, method, property, event or API contract is supported by the current operating system. If so, the app can then call the appropriate API.

For more info, please see Dynamically detecting features with API contracts (10 by 10) and also this question, Target code for a specific version of Windows 10, like Build 10586.

Upvotes: 2

Related Questions