获取 Windows Phone 手机系统信息

wpf:1161718192021222324252627282930…

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

全栈程序员社区此处内容已经被作者隐藏,请输入验证码查看内容
验证码:
请关注本站微信公众号,回复“验证码”,获取验证码。在微信里搜索“全栈程序员社区”或者“www_javaforall_cn”或者微信扫描右侧二维码都可以关注本站微信公众号。

wpf:

  1 <phone:PhoneApplicationPage
  2     x:Class="ABSystemInfo.MainPage"
  3     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5     xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
  6     xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
  7     xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
  8     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  9     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 10     mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
 11     FontFamily="{StaticResource PhoneFontFamilyNormal}"
 12     FontSize="{StaticResource PhoneFontSizeNormal}"
 13     Foreground="{StaticResource PhoneForegroundBrush}"
 14     SupportedOrientations="Portrait"  Orientation="Portrait"
 15     shell:SystemTray.IsVisible="True">
 16  
 17     <!--LayoutRoot is the root grid where all page content is placed-->
 18     <Grid x:Name="LayoutRoot" Background="Transparent">
 19         <!--Pivot Control-->
 20         <controls:Pivot Title="DEVICE INFO">
 21             <controls:PivotItem Header="device">
 22                 <Grid>
 23                     <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Height="607" Width="456">
 24                         <TextBlock Text="Device Manufacturer" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 25                         <TextBlock Text="0" Margin="10" Name="DeviceManufacturerTextBlock" FontSize="36" TextAlignment="Center"/>
 26                         <TextBlock Text="Device Name" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 27                         <TextBlock Text="0" Margin="10" Name="DeviceNameTextBlock" FontSize="36" TextAlignment="Center"/>
 28                         <TextBlock Text="Device Firmware Version" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 29                         <TextBlock Text="0" Margin="10" Name="DeviceFirmwareVersionTextBlock" FontSize="36" TextAlignment="Center"/>
 30                         <TextBlock Text="Device Hardware Version" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 31                         <TextBlock Text="0" Margin="10" Name="DeviceHardwareVersionTextBlock" FontSize="36" TextAlignment="Center"/>
 32                         </StackPanel>
 33  
 34                 </Grid>
 35             </controls:PivotItem>
 36  
 37             <controls:PivotItem Header="memory">
 38                 <Grid>
 39                     <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Height="607" Width="456">
 40                         <TextBlock Text="Application Current Memory Usage" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 41                         <TextBlock Text="0" Margin="10" Name="ApplicationCurrentMemoryUsageTextBlock" FontSize="36" TextAlignment="Center"/>
 42                         <TextBlock Text="Application Memory Usage Limit" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 43                         <TextBlock Text="0" Margin="10" Name="ApplicationMemoryUsageLimitTextBlock" FontSize="36" TextAlignment="Center"/>
 44                         <TextBlock Text="Application Peak Memory Usage" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 45                         <TextBlock Text="0" Margin="10" Name="ApplicationPeakMemoryUsageTextBlock" FontSize="36" TextAlignment="Center"/>
 46                         <TextBlock Text="DeviceTotalMemory" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 47                         <TextBlock Text="0" Margin="10" Name="DeviceTotalMemoryTextBlock" FontSize="36" TextAlignment="Center"/>
 48  
 49                     </StackPanel>
 50                 </Grid>
 51             </controls:PivotItem>
 52  
 53             <controls:PivotItem Header="hardware">
 54                 <Grid>
 55                     <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Height="607" Width="456">
 56                         <TextBlock Text="Is Keyboard Deployed?" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 57                         <TextBlock Text="0" Margin="10" Name="IsKeyboardDeployedTextBlock" FontSize="36" TextAlignment="Center"/>
 58                         <TextBlock Text="Is Keyboard Present?" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 59                         <TextBlock Text="0" Margin="10" Name="IsKeyboardPresentTextBlock" FontSize="36" TextAlignment="Center"/>
 60                         <TextBlock Text="Power Source" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 61                         <TextBlock Text="0" Margin="10" Name="PowerSourceTextBlock" FontSize="36" TextAlignment="Center"/>
 62                     </StackPanel>
 63                 </Grid>
 64             </controls:PivotItem>
 65  
 66             <controls:PivotItem Header="os">
 67                 <Grid>
 68                     <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Height="607" Width="456">
 69                         <TextBlock Text="Operating System" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 70                         <TextBlock Text="0" Margin="10" Name="OperatingSystemPlatformTextBlock" FontSize="36" TextAlignment="Center"/>
 71                         <TextBlock Text="Version" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 72                         <TextBlock Text="0" Margin="10" Name="OperatingSystemVersionTextBlock" FontSize="36" TextAlignment="Center"/>
 73                     </StackPanel>
 74                 </Grid>
 75             </controls:PivotItem>
 76  
 77             <controls:PivotItem Header="clr">
 78                 <Grid>
 79                     <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Height="607" Width="456">
 80                         <TextBlock Text="Major" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 81                         <TextBlock Text="0" Margin="10" Name="ClrMajorTextBlock" FontSize="36" TextAlignment="Center"/>
 82                         <TextBlock Text="Minor" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 83                         <TextBlock Text="0" Margin="10" Name="ClrMinorTextBlock" FontSize="36" TextAlignment="Center"/>
 84                         <TextBlock Text="Revision" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 85                         <TextBlock Text="0" Margin="10" Name="ClrRevisionTextBlock" FontSize="36" TextAlignment="Center"/>
 86                         <TextBlock Text="Build" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 87                         <TextBlock Text="0" Margin="10" Name="ClrBuildTextBlock" FontSize="36" TextAlignment="Center"/>
 88                     </StackPanel>
 89                 </Grid>
 90             </controls:PivotItem>
 91  
 92             <controls:PivotItem Header="unique ids">
 93                 <Grid>
 94                     <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Height="607" Width="456">
 95                         <TextBlock Text="Device Unique ID" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 96                         <TextBlock Text="0" Margin="10" Name="DeviceUniqueIDTextBlock" FontSize="36" TextAlignment="Center" TextWrapping="Wrap"/>
 97                         <TextBlock Text="Windows Live Anonymous ID" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
 98                         <TextBlock Text="0" Margin="10" Name="WindowsLiveAnonymousIDTextBlock" FontSize="36" TextAlignment="Center" TextWrapping="Wrap"/>
 99                     </StackPanel>
100                 </Grid>
101             </controls:PivotItem>
102         </controls:Pivot>
103     </Grid>
104 </phone:PhoneApplicationPage>

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 marketplace
100  
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 }

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/120761.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • SPI与IIC通信协议比对篇

    SPI与IIC通信协议比对篇目录一、SPI与IIC通信协议比对:二、SPI通信协议:(1)引脚简介(2)起始信号:标号①;停止信号:标号⑥(3)数据的有效性:②③④⑤(4)CPOL/CPHA及通讯模式三、IIC通信协议:(1)起始条件、停止条件(2)数据的有效性(3)主机写数据到从机(4)应答信号(ACK)与非应答信号(NACK)(5)字节格式(6)…

    2022年6月7日
    47
  • linux下socket编程实例_C语言窗口编程

    linux下socket编程实例_C语言窗口编程1.什么是TCP/IP、UDP?TCP/IP(TransmissionControlProtocol/InternetProtocol)即传输控制协议/网间协议,是一个工业标准的协议集,它是为广域网(WANs)设计的。  UDP(UserDataProtocol,用户数据报协议)是与TCP相对应的协议。它是属于TCP/IP协议族中的一种。下面的图表明了这些协议的关系。

    2022年10月7日
    2
  • flask中jsonify和json区别[通俗易懂]

    flask中jsonify和json区别[通俗易懂]JSON数据结构要把json与字典区分开来dumps(字典转换成Json)loads(Json转换成字典)参考:Python的字典是一种数据结构,JSON是一种数据格式。json就是一个根据某种约定格式编写的纯字符串,不具备任何数据结构的特征。而python的字典的字符串表现形式的规则看上去和json类似,但是字典本身是一个完整的数据结构,实现了一切自身该有的算法。Python的字典key可以是任意可hash对象,json只能是字符串。形式上有些相像,但JSO

    2022年5月23日
    50
  • webpack css_webpack打包css文件路径

    webpack css_webpack打包css文件路径css文件处理-准备工作(以下项目配置都是基于上一篇webpack(4)的基础上)在项目开发中,我们必然需要添加很多的样式,而样式我们往往写到一个单独的文件中。这里我们就在src目录中创建一个n

    2022年7月31日
    3
  • 基于IP路由的GSLB《CDN技术详解》

    基于IP路由的GSLB《CDN技术详解》基于IP路由的GSLB是基于路由器原有的路由算法和数据包转发能力工作的。如图所示,有两个本地均衡器1和2,放在不同的POP点中,负责各自POP点内的服务器的负载均衡。先为这两个本地均衡器配置一个相同的VIP地址,对IP网上的路由器来说,这是到同一个IP地址的两条不同的路由。1)当终端a输入URL访问网站时,DNS系统会把VIP作为域名解析结果反馈给终端。2)终端向这个VIP发送请求时,请求数…

    2022年5月22日
    46
  • vim 搜索字符串_python查找字符串位置

    vim 搜索字符串_python查找字符串位置搜索(查找)#搜索模式/ #前向搜索匹配? #反向搜索匹配#移动定位n #跳到下一个匹配的位置N #跳到上一个匹配的位置* #对光标当前所在的完整单词进行前向搜索匹配# #对光标当前所在的完整单词进行后向搜索匹配g*#前向搜索光标当前所在单词g##反向搜索光标当前所在单词搜索时字母大小写情况设置#设置vimrc文件#当输入的搜索词全部是小写时,忽略大小写;搜索词至少有一个大写字母时,进行大小写匹配搜索setignorecase

    2022年9月23日
    4

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号