Windows Phone 7 如何獲取用戶和手機的信息
using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using Microsoft.Phone.Info;namespace MicroBlogForWP7.Classes.Util { public class UserDeviceInfo { /// <summary> /// 獲取用戶唯一標識 /// </summary> /// <returns></returns> public static string GetUserID() { object anid = new object(); string anonymousUserId = ""; if (UserExtendedProperties.TryGetValue("ANID", out anid)) { if (null == anid) { return string.Empty; } anonymousUserId = anid as string; anonymousUserId = anonymousUserId.Substring(2, 32); } return anonymousUserId; }
/// <summary> /// 獲取設備唯一標識 /// </summary> /// <returns></returns> public static string GetDeviceUniqueId() { byte[] byteArray = DeviceExtendedProperties.GetValue("DeviceUniqueId") as byte[]; string strTemp = ""; string strDeviceUniqueID = ""; foreach (byte b in byteArray) { strTemp = b.ToString(); if (1 == strTemp.Length) { strTemp = "00" + strTemp; } else if (2 == strTemp.Length) { strTemp = "0" + strTemp; } strDeviceUniqueID += strTemp; } return strDeviceUniqueID; } /// <summary> /// 獲取設備生產廠商 /// </summary> /// <returns></returns> public static string GetDeviceManufacturer() { string strDeviceManufacturer = DeviceExtendedProperties.GetValue("DeviceManufacturer").ToString(); return strDeviceManufacturer; } /// <summary> /// 獲取當前應用程序使用的內存大小(單位是Byte) /// </summary> /// <returns></returns> public static string GetApplicationCurrentMemoryUsage() { string strDeviceManufacturer = DeviceExtendedProperties.GetValue("ApplicationCurrentMemoryUsage").ToString(); return strDeviceManufacturer; } /// <summary> /// 獲取設備名稱 /// </summary> /// <returns></returns> public static string GetDeviceName() { string strDeviceName = DeviceExtendedProperties.GetValue("DeviceName").ToString(); return strDeviceName; } /// <summary> /// 獲取設備固件版本 /// </summary> /// <returns></returns> public static string GetDeviceFirmwareVersion() { string strDeviceFirmwareVersion = DeviceExtendedProperties.GetValue("DeviceFirmwareVersion").ToString(); return strDeviceFirmwareVersion; } /// <summary> /// 獲取設備硬件版本 /// </summary> /// <returns></returns> public static string GetDeviceHardwareVersion() { string strDeviceHardwareVersion = DeviceExtendedProperties.GetValue("DeviceHardwareVersion").ToString(); return strDeviceHardwareVersion; } /// <summary> /// 獲取設備內存大小(單位是Byte) /// </summary> /// <returns></returns> public static string GetDeviceTotalMemory() { string strDeviceTotalMemory = DeviceExtendedProperties.GetValue("DeviceTotalMemory").ToString(); return strDeviceTotalMemory; } /// <summary> /// 獲取應用程序峰值內存大小(單位是Byte) /// </summary> /// <returns></returns> public static string GetApplicationPeakMemoryUsage() { string strApplicationPeakMemoryUsage = DeviceExtendedProperties.GetValue("ApplicationPeakMemoryUsage").ToString(); return strApplicationPeakMemoryUsage; } }}</pre>
本文由用戶 webphp 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!