6

I'm working windows 10 10240 Univasal windows app, when i use Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamilyVersion to get deivce version, it return a string "2814750438211605" instead of a version format (major.minor.revision.build). Anyone can tell me what the string "2814750438211605" means?

Filip Skakun
  • 31,624
  • 6
  • 74
  • 100
tao
  • 760
  • 1
  • 7
  • 16

4 Answers4

20

The Windows 10 OS version value is located in this string property:
Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamilyVersion

It returns string value like "2814750438211613".
To convert this long number to readable format use this:

string sv = AnalyticsInfo.VersionInfo.DeviceFamilyVersion;
ulong v = ulong.Parse(sv);
ulong v1 = (v & 0xFFFF000000000000L) >> 48;
ulong v2 = (v & 0x0000FFFF00000000L) >> 32;
ulong v3 = (v & 0x00000000FFFF0000L) >> 16;
ulong v4 = v & 0x000000000000FFFFL;
string version = $"{v1}.{v2}.{v3}.{v4}"; // == 10.0.10240.16413
xmedeko
  • 7,336
  • 6
  • 55
  • 85
Martin Suchan
  • 10,600
  • 3
  • 36
  • 66
  • thanks, it works but somehow don't know why it doesn't work on javascript.... Hope if anyone can answer me later..it gives 0 to me in the first digit. var version = 2814750438211613, v1 = (version & 0xFFFF000000000000) >>48, v2 = (version & 0x0000FFFF00000000) >> 32, v3 = (version & 0x00000000FFFF0000) >> 16, v4 = version & 0x000000000000FFFF; The first one will be wrong and give 0 instead of 10. – Thomas Lee Sep 21 '15 at 06:34
3

Your application should treat the as opaque data and just log it "as is". It's a 64-bit decimal value as a string.

Remember the intent of this API is to provide a log string from which you can reconstruct the OS version number for support/analytics. On your server-side analysis, you'd convert it if needed or just use it as a unique version identifier... If you are actually trying to parse it runtime, then you are using it incorrectly and quite likely to recreate same problems that resulted in GetVersionEx and VerifyVersionInfo being deprecated in the first place.

Do not parse the string at runtime in your app. Just store "as is" Remember that with Windows 10, a customer really has no idea what you mean if you ask "What version of Windows do you have?". The answer is "10" and will likely still be "10" for a long time to come.

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81
  • This does very little to aid in debugging issues from the field. If you want to get the full DFV logged in your analytics for debugging any issues, you've gotta go the route Martin mentioned above. – bc3tech Feb 26 '16 at 14:59
  • What you really need are crash dumps, yes? You can get those through the portal. – Chuck Walbourn Feb 26 '16 at 16:18
  • not necessarily. Any logging, really. "submit report" dialogs & emails... etc. – bc3tech Feb 28 '16 at 03:33
3

If you found this question and like me you are looking for a way to do this in JavaScript, then you might find this useful.

getDeviceFamilyVersion() {
    let deviceFamilyVersion = Windows.System.Profile.AnalyticsInfo.versionInfo.deviceFamilyVersion;
    let deviceFamilyVersionDecimalFormat = parseInt(deviceFamilyVersion);

    if (isNaN(deviceFamilyVersionDecimalFormat)) {
        throw new Error('cannot parse device family version number');
    }

    let hexString = deviceFamilyVersionDecimalFormat.toString(16).toUpperCase();

    while (hexString.length !== 16) { // this is needed because JavaScript trims the leading zeros when converting to hex string
        hexString = '0' + hexString;
    }

    let hexStringIterator = 0;
    let versionString = '';
    while (hexStringIterator < hexString.length) {
        let subHexString = hexString.substring(hexStringIterator, hexStringIterator + 4);
        let decimalValue = parseInt(subHexString, 16);

        versionString += decimalValue + '.';
        hexStringIterator += 4;
    }

    return versionString.substring(0, versionString.length - 1);
}
David Bohunek
  • 3,181
  • 1
  • 21
  • 26
0

Just a nifty way of doing this .. I Creadted a Enum that is used to match predefined device families

public enum DeviceFamily
{
    Unknown,
    Desktop,
    Tablet,
    Mobile,
    SurfaceHub,
    Xbox,
    Iot
}

This method will check and parse it into the enum.

   var q = ResourceContext.GetForCurrentView().QualifierValues;
    if (q.ContainsKey("DeviceFamily"))
    {
        try
        {
            Enum.Parse(typeof(DeviceFamily) , q["DeviceFamily"]);
            //send the user notification about the device family he is in.
        }
        catch (Exception ex) { }
    }
CodeCaster
  • 147,647
  • 23
  • 218
  • 272
Akash Gutha
  • 601
  • 8
  • 21