windows-phone-8.1 – 如何检测在Windows 10 Mobile上启动的WP8.1应用程序?
发布时间:2020-09-07 04:31:57 所属栏目: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)具有这两个属性.这就是我们如何检测应用程序运行的操作系统的方法. (编辑:东莞站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- JLink重刷固件(win7/win8/win10亲测可用)
- 重启后如何检测Windows服务器是否可用?
- Windows – Win32:如何将字符串转换为日期?
- npm ERR!注册表错误解析json – 尝试在Windows 8中安装Cor
- 如何在Windows上确定是否安装了C/C++编译器
- windows – 为什么模拟会话中定义的DOS设备不会出现在资源管
- 批处理文件 – Windows批处理将记录添加到主机文件
- Windows Server 2016 新功能HCI(超融合基础架构) By S2D
- Microsoft Dynamics(Navision)vs C#.NET
- 批处理文件 – 以编程方式更改和刷新图标(无需重新启动)
推荐文章
站长推荐
- 在windows平台下采用electron-packager打包elect
- windows-phone-8 – 适用于Windows Phone 8的企业
- windows – 带双引号参数的exec
- windows – ruby win32apistructs(VerQueryValue
- Windows:忘记本地账户开机密码,但记得住PIN码
- windows – 用户和内核之间的线程fs段寄存器切换
- jboss7.x – 无法登录到windows上的jboss 7.1管理
- winapi – Windows SDK 7.0的signtool中的signwi
- resolveLocalFileSystemURI错误代码5 windows ph
- 在Windows下的Java应用程序中编写C控制台应用程序
热点阅读
