在Windows 10 Iot Core中生成独特的硬件串口?

问题描述 投票:0回答:2

如何通过组合它们来获取设备硬件信息并生成唯一值?例如,我想生成一个唯一的代码(CPU序列号+ ram序列号+以太网mac地址等),那么如何在UWP中获得CPU或Ram序列号?

c# uwp windowsiot windows-iot-core-10
2个回答
0
投票

我在Windows.System.Profile命名空间中找到HardwareIdentification类以生成UniqueID。

   var token = HardwareIdentification.GetPackageSpecificToken(null);
   using (DataReader reader = DataReader.FromBuffer(token.Id))
   {
       byte[] bytes = new byte[token.Id.Length];
       reader.ReadBytes(bytes);
       string uniqueCode = Encoding.ASCII.GetString(bytes);
   }

有关更多信息,请参阅Microsoft Document

为此,请确保在目标设备上启用TPM,要启用TPM,必须从Windows设备门户中的TPM配置选项卡安装TPM。

提示:Raspberry pi没有任何内部TPM,因此您必须选择软件TPM仿真器(NoSecurity)然后安装它,对于Intel minnow board max和qualcomm dragonboard,您可以选择其他选项。设置并安装TPM后,设备重新启动,当它再次启动时,您可以在顶部看到的生成的代码始终是唯一的。


-2
投票

这不是一个完整的答案,但是,您可以使用以下代码找到CPU序列号,

string cpuInfo = string.Empty;
ManagementClass mc = new ManagementClass("win32_processor");
ManagementObjectCollection moc = mc.GetInstances();

foreach (ManagementObject mo in moc)
{
     cpuInfo = mo.Properties["processorID"].Value.ToString();
     break;
}
© www.soinside.com 2019 - 2024. All rights reserved.