wpf:

 <phone:PhoneApplicationPage
x:Class="ABSystemInfo.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True"> <!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Pivot Control-->
<controls:Pivot Title="DEVICE INFO">
<controls:PivotItem Header="device">
<Grid>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Height="607" Width="456">
<TextBlock Text="Device Manufacturer" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="DeviceManufacturerTextBlock" FontSize="36" TextAlignment="Center"/>
<TextBlock Text="Device Name" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="DeviceNameTextBlock" FontSize="36" TextAlignment="Center"/>
<TextBlock Text="Device Firmware Version" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="DeviceFirmwareVersionTextBlock" FontSize="36" TextAlignment="Center"/>
<TextBlock Text="Device Hardware Version" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="DeviceHardwareVersionTextBlock" FontSize="36" TextAlignment="Center"/>
</StackPanel> </Grid>
</controls:PivotItem> <controls:PivotItem Header="memory">
<Grid>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Height="607" Width="456">
<TextBlock Text="Application Current Memory Usage" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="ApplicationCurrentMemoryUsageTextBlock" FontSize="36" TextAlignment="Center"/>
<TextBlock Text="Application Memory Usage Limit" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="ApplicationMemoryUsageLimitTextBlock" FontSize="36" TextAlignment="Center"/>
<TextBlock Text="Application Peak Memory Usage" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="ApplicationPeakMemoryUsageTextBlock" FontSize="36" TextAlignment="Center"/>
<TextBlock Text="DeviceTotalMemory" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="DeviceTotalMemoryTextBlock" FontSize="36" TextAlignment="Center"/> </StackPanel>
</Grid>
</controls:PivotItem> <controls:PivotItem Header="hardware">
<Grid>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Height="607" Width="456">
<TextBlock Text="Is Keyboard Deployed?" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="IsKeyboardDeployedTextBlock" FontSize="36" TextAlignment="Center"/>
<TextBlock Text="Is Keyboard Present?" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="IsKeyboardPresentTextBlock" FontSize="36" TextAlignment="Center"/>
<TextBlock Text="Power Source" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="PowerSourceTextBlock" FontSize="36" TextAlignment="Center"/>
</StackPanel>
</Grid>
</controls:PivotItem> <controls:PivotItem Header="os">
<Grid>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Height="607" Width="456">
<TextBlock Text="Operating System" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="OperatingSystemPlatformTextBlock" FontSize="36" TextAlignment="Center"/>
<TextBlock Text="Version" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="OperatingSystemVersionTextBlock" FontSize="36" TextAlignment="Center"/>
</StackPanel>
</Grid>
</controls:PivotItem> <controls:PivotItem Header="clr">
<Grid>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Height="607" Width="456">
<TextBlock Text="Major" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="ClrMajorTextBlock" FontSize="36" TextAlignment="Center"/>
<TextBlock Text="Minor" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="ClrMinorTextBlock" FontSize="36" TextAlignment="Center"/>
<TextBlock Text="Revision" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="ClrRevisionTextBlock" FontSize="36" TextAlignment="Center"/>
<TextBlock Text="Build" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="ClrBuildTextBlock" FontSize="36" TextAlignment="Center"/>
</StackPanel>
</Grid>
</controls:PivotItem> <controls:PivotItem Header="unique ids">
<Grid>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Height="607" Width="456">
<TextBlock Text="Device Unique ID" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="DeviceUniqueIDTextBlock" FontSize="36" TextAlignment="Center" TextWrapping="Wrap"/>
<TextBlock Text="Windows Live Anonymous ID" Margin="10" Foreground="{StaticResource PhoneAccentBrush}" FontSize="24" TextAlignment="Center"/>
<TextBlock Text="0" Margin="10" Name="WindowsLiveAnonymousIDTextBlock" FontSize="36" TextAlignment="Center" TextWrapping="Wrap"/>
</StackPanel>
</Grid>
</controls:PivotItem>
</controls:Pivot>
</Grid>
</phone:PhoneApplicationPage>

MainPage.cs

 using System;
using System.Globalization;
using System.Windows;
using System.Windows.Threading;
using Microsoft.Phone.Info; namespace ABSystemInfo
{
public partial class MainPage
{
readonly DispatcherTimer _timer; private long _applicationCurrentMemoryUsage;
private long _applicationMemoryUsageLimit;
private long _applicationPeakMemoryUsage;
private long _deviceTotalMemory; private const int AnidLength = ;
private const int AnidOffset = ; public MainPage()
{
InitializeComponent();
LoadStaticInfo();
_timer = new DispatcherTimer();
_timer.Interval = new TimeSpan(, , );
_timer.Tick += TimerTick;
_timer.Start(); } void TimerTick(object sender, EventArgs e)
{
try
{
_applicationCurrentMemoryUsage = DeviceStatus.ApplicationCurrentMemoryUsage;
_applicationMemoryUsageLimit = DeviceStatus.ApplicationMemoryUsageLimit;
_applicationPeakMemoryUsage = DeviceStatus.ApplicationPeakMemoryUsage; _deviceTotalMemory = DeviceStatus.DeviceTotalMemory; ApplicationCurrentMemoryUsageTextBlock.Text = String.Format("{0} MB ({1} KB)", ((_applicationCurrentMemoryUsage / ) / ), (_applicationCurrentMemoryUsage / ));
ApplicationMemoryUsageLimitTextBlock.Text = String.Format("{0} MB ({1} KB)", ((_applicationMemoryUsageLimit / ) / ), (_applicationMemoryUsageLimit / ));
ApplicationPeakMemoryUsageTextBlock.Text = String.Format("{0} MB ({1} KB)", ((_applicationPeakMemoryUsage / ) / ), (_applicationPeakMemoryUsage / ));
DeviceTotalMemoryTextBlock.Text = String.Format("{0} MB ({1} KB)", ((_deviceTotalMemory / ) / ), (_deviceTotalMemory / )); IsKeyboardDeployedTextBlock.Text = DeviceStatus.IsKeyboardDeployed.ToString(CultureInfo.InvariantCulture);
IsKeyboardPresentTextBlock.Text = DeviceStatus.IsKeyboardPresent.ToString(CultureInfo.InvariantCulture);
PowerSourceTextBlock.Text = DeviceStatus.PowerSource.ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
} private void LoadStaticInfo()
{
DeviceFirmwareVersionTextBlock.Text = DeviceStatus.DeviceFirmwareVersion;
DeviceHardwareVersionTextBlock.Text = DeviceStatus.DeviceHardwareVersion;
DeviceManufacturerTextBlock.Text = DeviceStatus.DeviceManufacturer;
DeviceNameTextBlock.Text = DeviceStatus.DeviceName; OperatingSystemPlatformTextBlock.Text = Environment.OSVersion.Platform.ToString();
OperatingSystemVersionTextBlock.Text = Environment.OSVersion.Version.ToString(); ClrBuildTextBlock.Text = Environment.Version.Build.ToString(CultureInfo.InvariantCulture);
ClrMajorTextBlock.Text = Environment.Version.Major.ToString(CultureInfo.InvariantCulture);
ClrMinorTextBlock.Text = Environment.Version.Minor.ToString(CultureInfo.InvariantCulture);
ClrRevisionTextBlock.Text = Environment.Version.Revision.ToString(CultureInfo.InvariantCulture); string deviceUniqueId = String.Empty;
for (int i = ; i < GetDeviceUniqueId().GetLength(); i++)
{
deviceUniqueId += GetDeviceUniqueId().GetValue(i);
} DeviceUniqueIDTextBlock.Text = deviceUniqueId;
WindowsLiveAnonymousIDTextBlock.Text =
GetWindowsLiveAnonymousId().ToString(CultureInfo.InvariantCulture);
} //Note: to get a result requires ID_CAP_IDENTITY_DEVICE
// to be added to the capabilities of the WMAppManifest
// this will then warn users in marketplace public static byte[] GetDeviceUniqueId()
{
byte[] result = null;
object uniqueId;
if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId))
result = (byte[])uniqueId; return result;
} // NOTE: to get a result requires ID_CAP_IDENTITY_USER
// to be added to the capabilities of the WMAppManifest
// this will then warn users in 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;
}
}
}

获取 Windows Phone 手机系统信息的更多相关文章

  1. 使用C#获取Windows Phone手机的各种数据(转)

    转自:http://www.sum16.com/desinger/use-c-sharp-get-windows-phone-information.html 使用C#获取Windows Phone手 ...

  2. python使用wmi模块获取windows下的系统信息监控系统-乾颐堂

    Python用WMI模块获取Windows系统的硬件信息:硬盘分区.使用情况,内存大小,CPU型号,当前运行的进程,自启动程序及位置,系统的版本等信息. 本文实例讲述了python使用wmi模块获取w ...

  3. 几个获取Windows系统信息的Delphi程序

    1.获取windows版本信息 可以通过Windows API函数GetVersionEx来获得. 具体程序如下: Procedure Tform1.Button1Click(sender:TObje ...

  4. 通过PowerShell获取Windows系统密码Hash

    当你拿到了系统控制权之后如何才能更长的时间内控制已经拿到这台机器呢?作为白帽子,已经在对手防线上撕开一个口子,如果你需要进一步扩大战果,你首先需要做的就是潜伏下来,收集更多的信息便于你判断,便于有更大 ...

  5. js获取客户端计算机硬件及系统信息

    注意:(1):遇到“automation服务器不能创建对象”的问题 解决方案: 1.在“运行”中执行regsvr32 scrrun.dll 2.安全模式设置成“中”,如果javascript脚本中报这 ...

  6. [C语言](二)01 获取Windows图形构件大小信息

    SYSMETS.c #include <windows.h> #include "SYSMETS.H"//自定义的单元,所以用"",不是用<& ...

  7. 获取WINDOWS特殊文件夹

    const// registry entries for special paths are kept in :  REGSTR_PATH_SPECIAL_FOLDERS   = REGSTR_PAT ...

  8. VC++ 获取windows系统的版本类型

    vc中获取windows版本信息,一般是调用GetVersionEx 这个API函数来获取的,这个API需要OSVERSIONINFOEX 这个结构体作为参数,OSVERSIONINFOEX 的对应的 ...

  9. qt 获取windows 的消息(通过MFC的DLL的透明窗体转发消息)good

    qt 给win32 发送消息很简单,但是要获取windows 消息却十分复杂,最后想了一个不是很完美 但是也是以现在本人能力所能实现的唯一途径了,基本原理是 利用vc编写一个mfc 的dll ,这个d ...

随机推荐

  1. PHP中ob系列函数整理

    ob,输出缓冲区,是output buffering的简称,而不是output cache.ob用对了,是能对速度有一定的帮助,但是盲目的加上ob函数,只会增加CPU额外的负担. 下面我说说ob的基本 ...

  2. Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object

    本地原来已经安装了JAVA JDK1.7并配置好了环境变量; 然后又安装了JDK8,想2个版本并存. 然后发现eclipse 打不开,闪退.然后查看环境: 发现 C:\Users\Administra ...

  3. jQuery的ajax 方法提交多个对象数组问题 C# traditional $.param

    当用$.ajax()向后台提交参数时,如果参数中数组的话一般在后台会用List<T>接收;但老是不成功如下面代码 "}]; "}]; function addUser( ...

  4. JS - Constructor还可以这样用

    JS中Constructor好用法: 即在只知道一个对象实例的情况下(不知道对象名),重新初始化一个新实例: function Person( firstname, lastname, age ) { ...

  5. ODAC(V9.5.15) 学习笔记(十六)直接访问模式

    直接访问模式(Direct mode)是ODAC最大的特色之一,即不需要安装Oracle客户端,ODAC越过了OCI(Oracle Call Interface ),使用TCP/IP协议就可以直接与O ...

  6. 重构第3天:方法提公(Pull Up Method)

    理解:方法提公,或者说把方法提到基类中. 详解:如果大于一个继承类都要用到同一个方法,那么我们就可以把这个方法提出来放到基类中.这样不仅减少代码量,而且提高了代码的重用性. 看重构前的代码: usin ...

  7. 最近新装系统windows8.1+Mac。。。还没装驱动就遇到一堆问题。。。

    ---恢复内容开始--- 1,刚开始装好了,后来莫名看不到磁盘了,原因:64位mac盘会丢失盘符,所以macdrive也看不到...解决:(将AF改为06,修改内容后改回AF,早知道这么简单就不用重新 ...

  8. MyEclipse从数据库反向生成实体类之Hibernate方式 反向工程

    前文: hibernate带给我们的O/RMapping思想是很正确的,即从面相对象的角度来设计工程中的实体对象,建立pojo,然后在编写hbm.xml映射文件来生成数据表.但是在实际开发中,往往我们 ...

  9. MarkDown写blog(测试)

    区块元素 段落和换行 一个 Markdown 段落是由一个或多个连续的文本行组成,它的前后要有一个以上的空行(空行的定义是显示上看起来像是空的,便会被视为空行.比方说,若某一行只包含空格和制表符,则该 ...

  10. 【PRML读书笔记-Chapter1-Introduction】1.5 Decision Theory

    初体验: 概率论为我们提供了一个衡量和控制不确定性的统一的框架,也就是说计算出了一大堆的概率.那么,如何根据这些计算出的概率得到较好的结果,就是决策论要做的事情. 一个例子: 文中举了一个例子: 给定 ...