Windows 10 get DeviceFamilyVersion

后端 未结 4 1680
清酒与你
清酒与你 2020-12-06 07:51

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

4条回答
  •  伪装坚强ぢ
    2020-12-06 08:13

    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) { }
        }
    

提交回复
热议问题