wp7中如何獲取設備ID和用戶ID


private static readonly int ANIDLength = 32;  
        private static readonly int ANIDOffset = 2;  

  
        //需要在WMAppManifest  中添加 ID_CAP_IDENTITY_DEVICE  權限,並且用戶在marketplace下載程序的時候會有提示
        public static byte[] GetDeviceUniqueID()  
        {  
            byte[] result = null;  
            object uniqueId;  
            if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId))  
                result = (byte[])uniqueId;  
            return BitConverter.ToString(result, 0, result.Length);
        }  
  
        // 需要在WMAppManifest  中添加 ID_CAP_IDENTITY_USER  權限,並且用戶在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;  
        }  

來自WPDevN: http://www.wpdevn.com/showtopic-83.aspx


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM