从 Metro 应用程序检测桌面可用性(检测 ARM,检测 Windows RT 系统) [英] Detect Desktop availability from Metro application (detect ARM, detect Windows RT system)
问题描述
这是一个关于Get OS-Version in的问题WinRT Metro 应用程序 C# 但不是它的副本.
This is a question related to Get OS-Version in WinRT Metro App C# but not its duplicate.
是否有任何选项可以从 Metro 应用程序中检测系统上是否有可用的桌面功能?我知道不支持检测操作系统版本,这没关系.
Is there any option to detect from a Metro application whether there is the desktop feature available on the system? I understand that detection of the OS version is not supported and that is OK imo.
但是我的 Metro 应用需要知道它运行的系统上是否有可用的桌面.
However my metro app needs to know whether there is a Desktop available on the system it is running on.
我所说的桌面是指可扩展的桌面 - 桌面,可以安装 3rd 方桌面应用程序.正如我们所知,基于 ARM 的设备也将拥有桌面,但仅限于 Microsoft 内置程序.
By Desktop I mean extendable desktop - desktop, where 3rd party desktop applications can be installed. As we know ARM based units will have the desktop too, but only with Microsoft built-in programs.
我能否区分我的 Metro 应用程序是在具有不可扩展桌面的基于 ARM 的平板电脑上运行还是在具有可扩展桌面的所有其他(基于 Intel 的)设备上运行?
Can I distinguish whether my Metro app is running on a ARM based tablet with non-extendable desktop vs on all other (Intel based) devices with extendable desktop?
推荐答案
经过更广泛的搜索,我找到了 GetNativeSystemInfo 方法.提示立即出现在 SO 站点上 - 这个 问题.Windows Store 应用程序似乎完全支持这种方法 - 尽管使用了 pinvoke,但 App Cert Kit 测试运行顺利.
After some more extensive search I found GetNativeSystemInfo method. The hint was right away on SO site - this question. This approach seems to be fully supported by Windows Store applications - the App Cert Kit test ran smoothly despite the fact that pinvoke was used.
我最终得到了以下代码:
I ended up with the following code:
[DllImport("kernel32.dll")]
internal static extern void GetNativeSystemInfo(ref SystemInfo lpSystemInfo);
internal static bool IsArmBased()
{
var sysInfo = new SystemInfo();
GetNativeSystemInfo(ref sysInfo);
return sysInfo.wProcessorArchitecture == ProcessorArchitectureArm; //ushort 5
}
这似乎是我一直在寻找的解决方案.如果不是,请告诉我,或者让我知道与这种方法相关的任何问题.谢谢.
This seems to be as a solution I was looking for. Please tell me if not or make me aware of whatever problems connected to such an approach. Thank you.
这篇关于从 Metro 应用程序检测桌面可用性(检测 ARM,检测 Windows RT 系统)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!