windows-phone-8.1 – 如何检测在Windows 10 Mobile上启动的WP8.
发布时间:2020-12-13 21:26:20 所属栏目:Windows 来源:网络整理
导读:我需要在我的WP8.1应用程序代码中检查操作系统版本(WP 8.1或W10).有什么更好的方法呢?为此目的可能是反思或一些特殊的API? 我没有找到任何其他方法来做到这一点,所以这是我的方法. 以下属性IsWindows10检测Windows 10(包括Windows 10 Mobile)设备上是否运
我需要在我的WP8.1应用程序代码中检查操作系统版本(WP 8.1或W10).有什么更好的方法呢?为此目的可能是反思或一些特殊的API?
我没有找到任何其他方法来做到这一点,所以这是我的方法.
以下属性IsWindows10检测Windows 10(包括Windows 10 Mobile)设备上是否运行Windows 8.1或Windows Phone 8.1应用程序. #region IsWindows10 static bool? _isWindows10; public static bool IsWindows10 => (_isWindows10 ?? (_isWindows10 = getIsWindows10Sync())).Value; static bool getIsWindows10Sync() { bool hasWindows81Property = typeof(Windows.ApplicationModel.Package).GetRuntimeProperty("DisplayName") != null; bool hasWindowsPhone81Property = typeof(Windows.Graphics.Display.DisplayInformation).GetRuntimeProperty("RawPixelsPerViewPixel") != null; bool isWindows10 = hasWindows81Property && hasWindowsPhone81Property; return isWindows10; } #endregion 它是如何工作的? 在Windows 8.1中,Package类具有DisplayName属性,Windows Phone 8.1没有该属性.在Windows Phone 8.1中,DisplayInformation类具有RawPixelsPerViewPixel属性,Windows 8.1没有该属性.Windows 10(包括Mobile)具有这两个属性.这就是我们如何检测应用程序运行的操作系统的方法. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows-server-2008 – FTP错误530,用户无法登录,主目录无
- 如果正在使用端口,Windows批处理脚本将打印错误消息
- windows – 为什么我的用户的下载在IE中随机停止?
- Ionic – 在Windows上为IOS构建(适用于最新的IOS和Ionic)
- windows-server-2003 – 重用服务器名称
- 如何让Windows 2.7和Python 3.1在Windows 7上共存?
- windows-phone-7 – 如何更改Panorama项目标题的字号?
- windows-server-2012 – RDP适用于有线连接,但它在“估计连
- “无法找到指定的过程”错误与.NET 4
- Windows API一日一练 67 SetTimer和KillTimer函数
推荐文章
站长推荐
热点阅读