Detect Desktop availability from Metro application (detect ARM, detect Windows RT system)

删除回忆录丶 提交于 2019-12-23 18:23:00

问题


This is a question related to Get OS-Version in WinRT Metro App C# but not its duplicate.

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.

However my metro app needs to know whether there is a Desktop available on the system it is running on.

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.

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?


回答1:


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.




回答2:


If this is HTML, you can use window.cpuClass to get if it's ARM, x86 or amd64.

A non dynamic version is to use target specific architectures rather than AnyCPU, and then use the flavours with #ifdefs to hard code it at build time. You have to submit 3 packages to the store, however.




回答3:


Use a try {} catch(){} to access those libraries, if anything goes wrong assume the ARM version.



来源:https://stackoverflow.com/questions/12272399/detect-desktop-availability-from-metro-application-detect-arm-detect-windows-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!