Finding the device id in Windows 8

Posted: October 12, 2012 in Programming, Windows 8

One of many questions about Windows 8 is how to get the device ID, believe or not is not straightforward and for a long time i even ear many times that this wasn’t even possible. Apparently after RTM this becomes possible.

Many times you need this to grant:

-push notification correct behavior

-to grant that a authenticated app is running from some specific device (can be applied many times to bank and finance problems)

The Device ID is many times called App Specific Hardware ID or ASHWID in windows 8 language.


Today digging around to find the answer i found this great post of Wade Wegner that show us how to get this information in C#, you can read the article here You can also find a more complete description on Windows 8 specification


Basically in C# what you need to do is something similar to

private string GetHardwareId()
    var token = HardwareIdentification.GetPackageSpecificToken(null);
    var hardwareId = token.Id;
    var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);

    byte[] bytes = new byte[hardwareId.Length];

    return BitConverter.ToString(bytes);

In WinJS you would have something similar to

function getHardwareId(outId){
    var token = Windows.System.Profile.HardwareIdentification.getPackageSpecificToken(nonce);
    var hardwareId =;
    var signature = packageSpecificToken.signature;
    var certificate = packageSpecificToken.certificate;
    outId = hardwareId;


Hope this information can be useful for you.


  1. Mahantesh says:

    You can get device id using following class aslo:

    Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation device = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation();
    _MachineID = device.Id.ToByteArray();

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s