有兩個標識符可以一起用來標識特定的設備和用戶。
的DeviceUniqueId和WindowsLiveAnonymousId
第一個是設備,並且指出,誰使用禁止用戶後,器件也將被禁止。
WindowsLiveAnonymousId對用戶是唯一的。我已經在3個獨立的設備上看到了相同的標識符,並且用戶LiveId總是相同的。
我使用以下兩種方法來獲得這些ID識別遊戲玩家的領袖護板:
//Note: to get a result requires ID_CAP_IDENTITY_DEVICE
// to be added to the capabilities of the WMAppManifest
// this will then warn users in marketplace
public static byte[] GetDeviceUniqueId()
{
byte[] result = null;
object uniqueId;
if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId))
result = (byte[])uniqueId;
return result;
}
// NOTE: to get a result requires ID_CAP_IDENTITY_USER
// to be added to the capabilities of the WMAppManifest
// this will then warn users in marketplace
public static string GetWindowsLiveAnonymousId()
{
string result = String.Empty;
object anid;
if (UserExtendedProperties.TryGetValue("ANID", out anid))
{
if (anid != null && anid.ToString().Length >= (AnidLength + AnidOffset))
{
result = anid.ToString().Substring(AnidOffset, AnidLength);
}
}
return result;
}
它們被用作這樣的:
string deviceUniqueId = String.Empty;
for (int i = 0; i < GetDeviceUniqueId().GetLength(0); i++)
{
deviceUniqueId += GetDeviceUniqueId().GetValue(i);
}
DeviceUniqueIDTextBlock.Text = deviceUniqueId;
WindowsLiveAnonymousIDTextBlock.Text = GetWindowsLiveAnonymousId().ToString(CultureInfo.InvariantCulture);
我做了一個帖子去年五月約獲取WP7上的系統信息。此代碼在這裏找到:http://www.adambenoit.com/applications/system-info-windows-phone/
希望這可以幫助。
'獨一無二' 是ungradable形容詞。絕對不可能限定。 – NickT 2013-04-23 19:08:03