博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
获取 Windows Phone 手机系统信息
阅读量:5888 次
发布时间:2019-06-19

本文共 6548 字,大约阅读时间需要 21 分钟。

wpf:

1 
16 17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 34
35
36 37
38
39
40
41
42
43
44
45
46
47
48 49
50
51
52 53
54
55
56
57
58
59
60
61
62
63
64
65 66
67
68
69
70
71
72
73
74
75
76 77
78
79
80
81
82
83
84
85
86
87
88
89
90
91 92
93
94
95
96
97
98
99
100
101
102
103
104

MainPage.cs 

1 using System;  2 using System.Globalization;  3 using System.Windows;  4 using System.Windows.Threading;  5 using Microsoft.Phone.Info;  6    7 namespace ABSystemInfo  8 {  9     public partial class MainPage 10     { 11         readonly DispatcherTimer _timer; 12   13         private long _applicationCurrentMemoryUsage; 14         private long _applicationMemoryUsageLimit; 15         private long _applicationPeakMemoryUsage; 16         private long _deviceTotalMemory; 17   18         private const int AnidLength = 32; 19         private const int AnidOffset = 2; 20   21         public MainPage() 22         { 23             InitializeComponent(); 24             LoadStaticInfo(); 25             _timer = new DispatcherTimer(); 26             _timer.Interval = new TimeSpan(0, 0, 1); 27             _timer.Tick += TimerTick; 28             _timer.Start(); 29   30         } 31   32         void TimerTick(object sender, EventArgs e) 33         { 34             try 35             { 36                 _applicationCurrentMemoryUsage = DeviceStatus.ApplicationCurrentMemoryUsage; 37                 _applicationMemoryUsageLimit = DeviceStatus.ApplicationMemoryUsageLimit; 38                 _applicationPeakMemoryUsage = DeviceStatus.ApplicationPeakMemoryUsage; 39   40                 _deviceTotalMemory = DeviceStatus.DeviceTotalMemory; 41   42                 ApplicationCurrentMemoryUsageTextBlock.Text = String.Format("{0} MB ({1} KB)", ((_applicationCurrentMemoryUsage / 1024) / 1024), (_applicationCurrentMemoryUsage / 1024)); 43                 ApplicationMemoryUsageLimitTextBlock.Text = String.Format("{0} MB ({1} KB)", ((_applicationMemoryUsageLimit / 1024) / 1024), (_applicationMemoryUsageLimit / 1024)); 44                 ApplicationPeakMemoryUsageTextBlock.Text = String.Format("{0} MB ({1} KB)", ((_applicationPeakMemoryUsage / 1024) / 1024), (_applicationPeakMemoryUsage / 1024)); 45                 DeviceTotalMemoryTextBlock.Text = String.Format("{0} MB ({1} KB)", ((_deviceTotalMemory / 1024) / 1024), (_deviceTotalMemory / 1024)); 46   47                 IsKeyboardDeployedTextBlock.Text = DeviceStatus.IsKeyboardDeployed.ToString(CultureInfo.InvariantCulture); 48                 IsKeyboardPresentTextBlock.Text = DeviceStatus.IsKeyboardPresent.ToString(CultureInfo.InvariantCulture); 49                 PowerSourceTextBlock.Text = DeviceStatus.PowerSource.ToString(); 50             } 51             catch (Exception ex) 52             { 53                 MessageBox.Show(ex.Message); 54             } 55         } 56   57         private void LoadStaticInfo() 58         { 59             DeviceFirmwareVersionTextBlock.Text = DeviceStatus.DeviceFirmwareVersion; 60             DeviceHardwareVersionTextBlock.Text = DeviceStatus.DeviceHardwareVersion; 61             DeviceManufacturerTextBlock.Text = DeviceStatus.DeviceManufacturer; 62             DeviceNameTextBlock.Text = DeviceStatus.DeviceName; 63   64             OperatingSystemPlatformTextBlock.Text = Environment.OSVersion.Platform.ToString(); 65             OperatingSystemVersionTextBlock.Text = Environment.OSVersion.Version.ToString(); 66   67             ClrBuildTextBlock.Text = Environment.Version.Build.ToString(CultureInfo.InvariantCulture); 68             ClrMajorTextBlock.Text = Environment.Version.Major.ToString(CultureInfo.InvariantCulture); 69             ClrMinorTextBlock.Text = Environment.Version.Minor.ToString(CultureInfo.InvariantCulture); 70             ClrRevisionTextBlock.Text = Environment.Version.Revision.ToString(CultureInfo.InvariantCulture); 71   72             string deviceUniqueId = String.Empty; 73             for (int i = 0; i < GetDeviceUniqueId().GetLength(0); i++) 74             { 75                 deviceUniqueId += GetDeviceUniqueId().GetValue(i); 76             } 77   78             DeviceUniqueIDTextBlock.Text = deviceUniqueId; 79             WindowsLiveAnonymousIDTextBlock.Text = 80                 GetWindowsLiveAnonymousId().ToString(CultureInfo.InvariantCulture); 81         } 82   83         //Note: to get a result requires ID_CAP_IDENTITY_DEVICE 84         // to be added to the capabilities of the WMAppManifest 85         // this will then warn users in marketplace 86   87         public static byte[] GetDeviceUniqueId() 88         { 89             byte[] result = null; 90             object uniqueId; 91             if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId)) 92                 result = (byte[])uniqueId; 93   94             return result; 95         } 96   97         // NOTE: to get a result requires ID_CAP_IDENTITY_USER 98         //  to be added to the capabilities of the WMAppManifest 99         // this will then warn users in marketplace100  101         public static string GetWindowsLiveAnonymousId()102         {103             string result = String.Empty;104             object anid;105             if (UserExtendedProperties.TryGetValue("ANID", out anid))106             {107                 if (anid != null && anid.ToString().Length >= (AnidLength + AnidOffset))108                 {109                     result = anid.ToString().Substring(AnidOffset, AnidLength);110                 }111             }112  113             return result;114         }115     }116 }

 

转载地址:http://mvrix.baihongyu.com/

你可能感兴趣的文章
2016的ChinaJoy沦为ChinaVR?
查看>>
Unity Shaders and Effets Cookbook
查看>>
cairo-1.14.6 static compiler msys mingw32
查看>>
Mac osx 下让android 模拟器横屏
查看>>
SQL创建触发器
查看>>
喜爱看剑雨,数据流的本人对各主角…
查看>>
luogu P1387 最大正方形
查看>>
Android图片圆角效果
查看>>
MSSQL跨服务器数据库查询
查看>>
WeChat Official Account Admin Platform API Introduction
查看>>
C语言写单链表的创建、释放、追加(即总是在最后的位置增加节点)
查看>>
poj1635
查看>>
C# LINQ详解(一)
查看>>
视频直播点播nginx-rtmp开发手册中文版
查看>>
iphone 添加CFNetwork.framework时,报错 socket
查看>>
ruby学习总结04
查看>>
Binary Tree Paths
查看>>
RESTful 架构详解(转)
查看>>
Ueditor自定义ftp上传
查看>>
线程以及多线程
查看>>