Windows 10 UAP determine if device is IoT (e.g. Raspberry Pi 2)

ぃ、小莉子 提交于 2019-12-07 19:09:28

问题


I was wondering how to determine if the device belongs to the IoT-family, in my case a Raspberry Pi 2, but I don't need to know if it is specifically a Raspberry, just an IoT device.

I tried the following code:

//if(ApiInformation.IsApiContractPresent("DevicesLowLevelContract ", 1))
if (ApiInformation.IsTypePresent("Windows.Devices.Gpio"))
{
    this.InitializeSensor();
    return;
}

Both wont be true on my notebook, but wont be true as well on my Rasbperry Pi. Has someone an idea or knows how to do it right?


回答1:


I would expect that property

Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily

is what you are looking for - it should return something like "Windows.IoT" in your case, since when I've checked it in universal app on desktop it was "Windows.Desktop" and on the phone with Windows 10 Mobile (preview) it was, well, "Windows.Mobile".




回答2:


With ApiInformation.IsTypePresent you are looking for a type not for a namespace. "Windows.Devices.Gpio" is a namespace. Try using the method with "Windows.Devices.Gpio.GpioController" instead.

I recommend working with the typeof keyword here to avoid working with strings. Like this:

ApiInformation.IsTypePresent(typeof(Windows.Devices.Gpio.GpioController).ToString());



回答3:


I'm struggling with the same issue, see: How to detect running on a real device?

Unfortunately IsTypePresent for the GpioController class returns true on desktop as well.



来源:https://stackoverflow.com/questions/30479171/windows-10-uap-determine-if-device-is-iot-e-g-raspberry-pi-2

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