UWP应用获取系统版本:

简单获取版本号:

string deviceFamilyVersion = AnalyticsInfo.VersionInfo.DeviceFamilyVersion;
        ulong version = ulong.Parse(deviceFamilyVersion);
        ulong major = (version & 0xFFFF000000000000L) >> 48;
        ulong minor = (version & 0x0000FFFF00000000L) >> 32;
        ulong build = (version & 0x00000000FFFF0000L) >> 16;
        ulong revision = (version & 0x000000000000FFFFL);
        var osVersion = $"{major}.{minor}.{build}.{revision}"

获取详细版本名称并处理:

public class SystemBuildVersionInfo
{
    private static SystemBuildVersionInfo _SystemBuildVersionInfo;

    private SystemBuildVersionInfo()
    {
        if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5))
        {
            Build = Build.FallCreators;
        }
        else if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 4))
        {
            Build = Build.Creators;
        }
        else if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 3))
        {
            Build = Build.Anniversary;
        }
        else if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 2))
        {
            Build = Build.Threshold2;
        }
        else if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 1))
        {
            Build = Build.Threshold1;
        }
        else
        {
            Build = Build.Unknown;
        }

        if (!BeforeCreatorsUpdate)
        {
            var capabilities = CompositionCapabilities.GetForCurrentView();
            capabilities.Changed += (s, e) => UpdateCapabilities(capabilities);
            UpdateCapabilities(capabilities);
        }

        void UpdateCapabilities(CompositionCapabilities capabilities)
        {
            AreEffectsSupported = capabilities.AreEffectsSupported();
            AreEffectsFast = capabilities.AreEffectsFast();
        }
    }

    public static Build Build { get; private set; }
    public static bool AreEffectsFast { get; private set; }
    public static bool AreEffectsSupported { get; private set; }
    public static bool BeforeCreatorsUpdate => Build < Build.Creators;

    public static SystemBuildVersionInfo RetrieveApiInfo() => _SystemBuildVersionInfo ?? (_SystemBuildVersionInfo = new SystemBuildVersionInfo());
}

public enum Build
{
    Unknown = 0,
    Threshold1 = 1507,   // 10240
    Threshold2 = 1511,   // 10586
    Anniversary = 1607,  // 14393 Redstone 1
    Creators = 1703,     // 15063 Redstone 2
    FallCreators = 1709  // 16299 Redstone 3
}