我在Windows 10 IoT核心[版本10.0.15063](Raspberry PI 3)上尝试了此方法(在https://stackoverflow.com/a/31803247/2427812上找到)以获取HardwareId,但每次设备重新启动时GetId()的结果都会更改。
你知道为什么会这样吗?
private static string GetId()
{
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.System.Profile.HardwareIdentification"))
{
var token = HardwareIdentification.GetPackageSpecificToken(null);
var hardwareId = token.Id;
var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
byte[] bytes = new byte[hardwareId.Length];
dataReader.ReadBytes(bytes);
return BitConverter.ToString(bytes).Replace("-", "");
}
throw new Exception("NO API FOR DEVICE ID PRESENT!");
}