Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 257
Jan Zeman Avatar asked Dec 07 '25 02:12

Jan Zeman


2 Answers

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.

like image 83
Jan Zeman Avatar answered Dec 09 '25 06:12

Jan Zeman


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.

like image 35
Dominic Hopton Avatar answered Dec 09 '25 05:12

Dominic Hopton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!