2010-12-20 71 views
8

有沒有一種方法可以唯一標識我的應用正在運行的Windows Phone設備?有沒有Windows手機設備ID或什麼?獲取當前windows phone 7設備的ID

+1

重複:http://stackoverflow.com/questions/4037862/will-there-be-a-unique-and-unchanging-device-id-that-apps-have-access-to-window – 2010-12-20 10:20:59

回答

19
object uniqueID; 
if (Microsoft.Phone.Info.DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueID)==true) { 
    byte[]bID=(byte[])uniqueID; 
    string deviceID=Convert.ToBase64String(bID); // There you go 
} 
4

或者你也可以在一般的 http://msdn.microsoft.com/en-us/library/system.guid.aspx 使用一個全局唯一標識符(GUID),並保存在本地存儲該ID。

deviceID = Guid.NewGuid(); 
IsolatedStorageSettings.ApplicationSettings["DeviceId"] = deviceID; 
+0

存儲在本地存儲我忘了提及 – 2011-04-27 16:55:29