如何获得windows phone 8.1的设备唯一Id ?
本文关键字:唯一 Id 何获得 windows phone | 更新日期: 2023-09-27 18:09:09
我想要唯一的设备Id为后端服务(ws),我发现以下参考
private string GetDeviceId()
{
var token = Windows.System.Profile.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("-", "");
}//Note: This function may throw an exception.
但是,我无法理解代码,每次我得到相同的Id为我的设备(64个字符串),我想知道它是否适用?我在MSDN上也找不到任何参考
Thank you
这可能有帮助:
private string GetDeviceID()
{
HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null);
IBuffer hardwareId = token.Id;
HashAlgorithmProvider hasher = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Md5);
IBuffer hashed = hasher.HashData(hardwareId);
string hashedString = CryptographicBuffer.EncodeToHexString(hashed);
return hashedString;
}
有关文档,请查看HardwareIdentification类中的GetPackageSpecificToken方法。