How to get System Information on Windows Phone 7

No.of Views2504
Bookmarked0 times
Downloads 
Votes0
By  j2inet   On  06 Nov 2010 00:11:08
Tag : Windows Phone , Miscellaneous
In this article, i'm going to show to you,How to get System Information on Windows Phone 7
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

There's a requirement that Windows Phone 7 applications not use more than 90 MB of memory to run. One might wonder how to know how much memory that their program is consuming. You can find that information through the DeviceExtendedProperties class. Given the myrid of programs on Windows Mobile and Android devices that display the technical details of a device I know it is tempting to surface some of this information up to a user. But Microsofts guidance on using it is that the information shouldn't be surfaced. Nor should you try to parse or process this information on the device. Rather the information exposed through this API should be for diagnostic purposes. Note that using this API in your programs will cause the program to need the DeviceInformation permission.

The DeviceExtendedProperties class has two methods that are of interest. object GetString(string) and bool TryGetString(String, out object). For both methods the string argument is the name of the property to be retrieved. The first method will return the value of a property of throw an exception of that property cannot be read. The second method will return true and copy the value of a property to the out variable if the property can be read, otherwise it returns false.

Some of the properties may not have values or may be blank. Here are some of the properties that can be retrieved 

Image Loading

To demonstrate the use of this class there's a link to download sample code at the top of this article. The code retrieves the values for a few of these properties and displays them.

C# Code

public void UpdateProperties()
        {object temp = null;
            ;
            DeviceManufacturer = (DeviceExtendedProperties.TryGetValue("DeviceManufacturer", out temp))
                                     ? (temp as string)
                                     : String.Empty;
            DeviceName = (DeviceExtendedProperties.TryGetValue("DeviceName", out temp) 
                                    ? (temp as string) : string.Empty);
            DeviceUniqueID = (DeviceExtendedProperties.TryGetValue("DeviceUniqueID", out temp)
                                    ? (temp as byte[])
                                    : new byte[0]);
            DeviceFirmwareVersion = (DeviceExtendedProperties.TryGetValue("DeviceFirmwareVersion", out temp)
                                    ? (temp as string)
                                    : String.Empty);
            DeviceHardwareVersion = (DeviceExtendedProperties.TryGetValue("DeviceHardwareVersion", out temp)
                                    ? (temp as string)
                                    : String.Empty);
            DeviceTotalMemory = (long)DeviceExtendedProperties.GetValue("DeviceTotalMemory");
            ApplicationCurrentMemoryUsage = (long) DeviceExtendedProperties.GetValue("ApplicationCurrentMemoryUsage");
            ApplicationPeakMemoryUsage = (long) DeviceExtendedProperties.GetValue("ApplicationPeakMemoryUsage");
        }

Output 

Image Loading

Download Sample Project 

Download source files -130 kb

 
Sign Up to vote for this article
 
About Author
 
j2inet
Occupation-Not Provided
Company-Not Provided
Member Type-Senior
Location-Not Provided
Joined date-12 Jun 2009
Home Page-Not Provided
Blog Page-Not Provided
 
 
Other popularSectionarticles
    In this article we will retrieve data from SharePoint list and display it Windows 7 phone application.
    Published Date : 03/Dec/2010
    In this article , i will show to how solve WCF Data Service Client library bug for Windows Phone 7.
    Published Date : 07/Jul/2010
    Introducing Windows Phone 7 Series
    Published Date : 11/Apr/2010
    In this article I will explain, how to handle buffer the entire recording in memory before writing it to a file. A rather astute reader asked me what would happen if the user let the recording go long enough to fill up memory. The answer to that question is the application would crash due to an exception being thrown when it fails to allocate more memory and all of the recording would be lost.
    Published Date : 21/May/2011
    You've got a class that contains data that you want to be able to save and load in IsolatedStorage on Windows Phone 7. How would you go about doing that? There is more than one way, but I wanted to share a generic solution for didactic purposes; I'm finding that many beginners like to start off with a single satisfying solution and brance off into specialized solutions later. Let's say that you are starting off with a stereotypical Employee class.
    Published Date : 05/Mar/2011
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top
</