这是我的旧实现,目的是为Windows Universal 8.1获取唯一的DeviceID,但是HardwareIdentification类型已经不存在了。
private static string GetId()
{
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("-", "");
}
发布于 2015-07-31 23:33:27
Windows 1609更新(“周年纪念更新”)
有关获取ID的更好方法,请参阅this Q&A。
旧操作系统版本的旧信息
您需要添加对桌面和/或移动SDK的引用,以根据硬件令牌进行构建。在运行时,在使用ApiInformation
之前,您应该使用API类型来查询它是否存在(其他设备系列,如Xbox没有)。
也就是说,很多时候,当人们询问设备ID时,这实际上不是解决他们问题的最佳解决方案--您确定需要在物理设备的整个生命周期中识别它吗,即使所有权发生了变化?
发布于 2016-08-04 17:28:28
EasClientDeviceInformation不适用于Windows10移动版。每部手机的设备id都是一样的(我们所有的win10m客户都是用相同的GUID注册的)我们需要这个id来向正确的手机发送推送消息。
发布于 2018-08-30 02:29:01
//you can use this
//its working with me very fine on windows 10
//replace the word bios with any hardware name you want
//data also can be found with using windows application named (wbemtest)
using System.Management;
public static async Task<string> ReturnHardWareID()
{
string s = "";
Task task = Task.Run(() =>
{
ManagementObjectSearcher bios = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS");
ManagementObjectCollection bios_Collection = bios.Get();
foreach (ManagementObject obj in bios_Collection)
{
s = obj["SerialNumber"].ToString();
break; //break just to get the first found object data only
}
});
Task.WaitAll(task);
return await Task.FromResult(s);
}
https://stackoverflow.com/questions/31746613
复制相似问题