简体   繁体   English

如何获得Windows Phone 8.1的设备唯一ID?

[英]How can I get Device Unique Id for windows phone 8.1?

I want Unique Device Id for back_end service (ws) for that I found following reference 我想要在以下参考资料中找到的用于后端服务(ws)的唯一设备ID

  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. 

but, I can't understand the code , every time I get same Id for my Device (64 character string ), I want to know that it is applicable or not ? 但是,我无法理解代码,每次我为设备获得相同的ID(64个字符串)时,我想知道它是否适用? I couldn't found any reference from MSDN also 我也找不到MSDN的任何参考

Thank you 谢谢

This may help: 这可能会有所帮助:

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;
}

For the documentation, have a look at the GetPackageSpecificToken method in the HardwareIdentification class. 对于文档,请查看HardwareIdentification类中的GetPackageSpecificToken方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM