Getting the Device GUID

Sometime you may want to uniquely identify a Windows Phone, such as when you are implementing push notifications. The best way to identify a unique Windows Phone is through its device GUID.
 
The following code snippet shows how to obtain the GUID of a Windows Phone device:
 
using Microsoft.Phone.Info;
 
    public static byte[] DeviceId()
    {
        object uniqueId;
        if (DeviceExtendedProperties.TryGetValue(
        "DeviceUniqueId", out uniqueId))
        {
            return (byte[])uniqueId;
        }
        return null;
    }
    ...
    ...
 
    byte[] guid = DeviceId();           
    MessageBox.Show("Device GUID - " +

 

        Convert.ToBase64String(guid));

For the code above to work, you need to check the ID_CAP_IDENTITY_DEVICE setting in your WMAppManifest.xml file.
posted @ 2013-11-13 16:00  MinieGoGo  阅读(231)  评论(0)    收藏  举报