[Windwos Phone 7] Getting device information

Source: Internet
Author: User

Abstract: This is the encapsulation of device information that can be obtained by windwos Phone 7 currently.

 
 
/// <Summary> /// get device information for Windows Phone /// </Summary> public class deviceinfo {Private Static readonly int anidlength = 32; private Static readonly int anidoffset = 2; # region-devicemanufacturer-// note: the name of the manufacturer of the device. // there is no standard format for this string. // It is recommended that the same value be used by every device from a manufacturer, // But this is not enforced. this value may be empty. public static string getmanufacturer () {string result = string. empty; object manufacturer; If (deviceextendedproperties. trygetvalue ("devicemanufacturer", out manufacturer) Result = manufacturer. tostring (); return result ;}# endregion # region-devicename-// note: the name of the device. // there is no standard format for this string. // This V Alue may be empty. public static string getdevicename () {string result = string. empty; object devicename; If (deviceextendedproperties. trygetvalue ("devicename", out devicename) Result = devicename. tostring (); return result ;}# endregion # region-deviceuniqueid-// 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 ;}# endregion # region-devicefirmwareversion-// note: the firmware version running on the device. // This is not the same as the OS version, which can be retrieved using system. env Ironment. // It is recommended that the value be a string that can be parsed as a system. version structure // and that it be incremented in a logical manner as newer firmware is installed, but this is not required. // this value may be empty. public static version getdevicefirmwareversion () {string result = string. empty; object devicefirmwareversion; If (deviceextendedproperties. trygetvalue ("devicef Irmwareversion ", out devicefirmwareversion) Result = devicefirmwareversion. tostring (); version = new version (devicefirmwareversion. tostring (); Return version;} # endregion # region-devicehardwareversion-// note: the hardware version running of the device. // This is not the same as the OS version, which can be retrieved using system. environment. // It is recommended that the value be a St Ring that can be parsed as a system. version structure // and that it be incremented in a logical manner as newer hardware is released, but this is not required. // this value may be empty. public static version getdevicehardwareversion () {string result = string. empty; object devicefirmwareversion; If (deviceextendedproperties. trygetvalue ("devicehardwareversion", out devicefirmwareversion) Result = Devicefirmwareversion. tostring (); version = new version (devicefirmwareversion. tostring (); Return version ;}# endregion # region-devicetotalmemory-// note: the device's physical Ram size in bytes. // This value will be less than the actual amount of device memory, // but can be used for determining memory consumption requirements. public static long getdevicetotalmemory () {long result = 0; Object devicetotalmemory; If (deviceextendedproperties. trygetvalue ("devicetotalmemory", out devicetotalmemory) Result = convert. toint64 (devicetotalmemory); return result ;}# endregion # region-applicationcurrentmemoryusage-// note: the current application's memory usage in bytes. public static long getapplicationcurrentmemoryusage () {long result = 0; object applicationcurrentmemoryusage; If (Deviceextendedproperties. trygetvalue ("applicationcurrentmemoryusage", out applicationcurrentmemoryusage) Result = convert. toint64 (applicationcurrentmemoryusage); return result ;}# endregion # region-applicationpeakmemoryusage-// note: the current application's peak memory usage in bytes. public static long getapplicationpeakmemoryusage () {long result = 0; object applicationpeakmemoryusage; If (Deviceextendedproperties. trygetvalue ("applicationpeakmemoryusage", out applicationpeakmemoryusage) Result = convert. toint64 (applicationpeakmemoryusage); return result ;}# endregion # region-windowsliveid-// 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 getwindowslivean Onymousid () {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 ;}# endregion}

For more information, see msdn

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.