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