簡體   English   中英

如何獲得Windows Phone 8.1的設備唯一ID?

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

我想要在以下參考資料中找到的用於后端服務(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. 

但是,我無法理解代碼,每次我為設備獲得相同的ID(64個字符串)時,我想知道它是否適用? 我也找不到MSDN的任何參考

謝謝

這可能會有所幫助:

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方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM