欢迎访问移动开发之家(rcyd.net),关注移动开发教程。移动开发之家  移动开发问答|  每日更新
页面位置 : > > 内容正文

wp7中如何获取设备ID和用户ID

来源: 开发者 投稿于  被查看 30299 次 评论:26

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

 
摘自  Spider_net

相关文章

    暂无相关文章
相关频道:

用户评论