WinPhone 开发(6)-----获得手机设备的基本信息

 

手机设备的基本信息包括制造商、设备名称、固件、硬件版本等,我们均可以通过  Microsoft.Phone.Info.DeviceStatus 下的一些方法直接得到,非常简单。

获得设备唯一标识那段code是网上copy回来的(出处忘了),但弄不懂其中的 0,00 处理方法是如何得来的。




View Code
  1 #region 加载手机的基本信息 + private void BindBaseInfo()
2 /// <summary>
3 /// 加载手机的基本信息
4 /// </summary>
5 private void BindBaseInfo()

6 {
7
8 StringBuilder sb = new StringBuilder();
9
10 //设备制造商名称
11 string str = DeviceStatus.DeviceManufacturer.ToString();

12 txtManufacturer.Text = "制造商: " + str;
13
14 //设备名称
15 str = DeviceStatus.DeviceName.ToString();

16 sb.AppendLine("设备名称: " + str);
17 sb.AppendLine();
18
19 //设备运行的固件版本
20 str = DeviceStatus.DeviceFirmwareVersion.ToString();

21 sb.AppendLine("固件版本: " + str);
22 sb.AppendLine();
23
24 //设备运行的硬件版本
25 str = DeviceStatus.DeviceHardwareVersion.ToString();

26 sb.AppendLine("硬件版本: " + str);
27 sb.AppendLine();
28
29
30 //使用外部电源还是手机电源
31 str = DeviceStatus.PowerSource.ToString();

32 sb.AppendLine("手机电源: " + str);
33 sb.AppendLine();
34
35 //是否已经部署设备的物理硬件键盘
36 if (DeviceStatus.IsKeyboardDeployed == true)

37 {
38 sb.AppendLine("物理键盘: 已部署");
39 }
40 else
41 {
42 sb.AppendLine("物理键盘: 未部署");
43 }
44 sb.AppendLine();
45
46 //设备是否包含物理硬件键盘
47 if (DeviceStatus.IsKeyboardPresent == true)

48 {
49 sb.AppendLine("虚拟键盘: 已内置");
50 }
51 else
52 {
53 sb.AppendLine("虚拟键盘: 未内置");
54 }
55 sb.AppendLine();
56
57 string anonymousUserId = "";
58 try
59 {
60 string anid = UserExtendedProperties.GetValue("ANID") as string;
61 anonymousUserId = anid.Substring(2, 32);
62 }
63 catch (Exception)
64 {
65
66 anonymousUserId = "手机还没有绑定Live ID";
67 }
68 sb.AppendLine("用户唯一标识: " + anonymousUserId);
69 sb.AppendLine();
70
71 //设备唯一标识
72 byte[] byteArray = DeviceExtendedProperties.GetValue("DeviceUniqueId") as byte[];

73 string strTemp = "";
74 string strDeviceUniqueID = "";
75 foreach (byte b in byteArray)
76 {
77 strTemp = b.ToString();
78 if (1 == strTemp.Length)
79 {
80 strTemp = "00" + strTemp;
81 }
82 else if (2 == strTemp.Length)
83 {
84 strTemp = "0" + strTemp;
85 }
86 strDeviceUniqueID += strTemp;
87 }
88
89 sb.AppendLine("设备唯一标识: " + strDeviceUniqueID);
90 sb.AppendLine();
91
92 txtView.Text = sb.ToString();
93
94 //str = MediaCapabilities.IsMultiResolutionVideoSupported.ToString();
95 //sb.AppendLine("是否支持多分辨率编码的视频的平滑流:" + str.ToString());
96

97 }
98 #endregion
99
100 #region 加载存储信息 + private void BindStorage()
101 /// <summary>
102 /// 加载存储信息
103 /// </summary>
104 private void BindStorage()

105 {
106
107 //设备的物理RAM大小,字节
108 int dTotalMemory = (int)DeviceStatus.DeviceTotalMemory / 1024 / 1024;

109 txtStorageImage.Text = "物理内存: " + dTotalMemory + " MB";
110
111
112 //应用程序进程可分配的最大额外内存量
113 int dMemoryUsageLimit = (int)DeviceStatus.ApplicationMemoryUsageLimit / 1024 / 1024;

114 txtMemoryUsageLimit.Text = "可分配的最大内存: " + dMemoryUsageLimit + " MB";
115
116 //当前应用程序的内存使用情况
117 int dMemoryUsage = (int)DeviceStatus.ApplicationCurrentMemoryUsage / 1024 / 1024;

118 txtMemoryUsage.Text = "当前程序已使用: " + dMemoryUsage + " MB";
119
120 //当前应用程序的高峰使用情况
121 int dApplicationPeakMemoryUsage = (int)DeviceStatus.ApplicationPeakMemoryUsage / 1024 / 1024;

122 txtPeakMemoryUsage.Text = "当前程序的高峰使用: " + dApplicationPeakMemoryUsage + " MB";
123
124 }
125 #endregion






posted @ 2012-03-15 21:16  Nereus_37  阅读(1047)  评论(0编辑  收藏  举报