I read a lot of stackoverflow post, but there was no solution for my problem. I want to get the version number of the running Windows 10 installation (e.g. 1809 or 1909) in C# or WinJS I develop an UWP app with Cordova (Javascript) and I have also a Cordova plugin (winmd) in C# which I can use, but there is no api to get this 4 digit version number.
I have a WinJS/Javascript code which was working fine till version 1903:
var ApiInformation = Windows.Foundation.Metadata.ApiInformation;
if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 9)) {
return 9999; // TODO: fix this build number, when it is released
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) {
return 1903;
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 7)) {
return 1809;
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 6)) {
return 1803;
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 5)) {
return 1709
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 4)) {
return 1703;
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 3)) {
return 1607;
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 2)) {
return 1511;
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 1)) {
return 1507;
} else {
return 0;
}
But because Windows 10 1909 is only a bugfix version with no own SDK, there is also no new UniversalApiContract version. So on a Windows 1909 installation the check for UniversalApiContract "9" returns "false" and so it returns "1903" instead "1909".
Are there some developers out there, who find out something in version 1909, which is new or unique to 1909, so we can check for this and say that this is version 1909?
Important: I am developing an UWP app and Windows has a sandbox concept for UWP apps, so there are some limitations, e.g. UWP apps cannot access the registry or the whole filesystem.
[UPDATE] Thanks Peter! It works now.
I use it in UWP Cordova WinJS/Javascript with this code:
var v = Windows.System.Profile.AnalyticsInfo.versionInfo.deviceFamilyVersion;
var major = (v & 0xFFFF000000000000) >> 48;
var minor = (v & 0x0000FFFF00000000) >> 32;
var build = (v & 0x00000000FFFF0000) >> 16;
var release = v & 0x000000000000FFFF;
if (build == 18363)
return 1909;
if (build == 18362)
return 1903;
I had to use Windows.System.Profile.AnalyticsInfo.versionInfo.deviceFamilyVersion, because Windows.System.Profile.AnalyticsVersionInfo.deviceFamilyVersion was "undefined" with the hint "Permission denied"? But the code above works.
You can use AnalyticsInfo.VersionInfo.DeviceFamilyVersion
to get the version number.
The property is a string which contains some digits. Parse the string into a 32-bit number, and then each byte of that 32-bit number forms part of a standard A.B.C.D
version.