问题
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