Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a Unique Identifier for a Device within Windows 10 Universal?

This is my old implementation to get a Unique DeviceID for Windows Universal 8.1 but the type HardwareIdentification does not exist anymore.

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

        byte[] bytes = new byte[hardwareId.Length];
        dataReader.ReadBytes(bytes);

        return BitConverter.ToString(bytes).Replace("-", "");
    }
like image 407
Jens Marchewka Avatar asked Jul 31 '15 12:07

Jens Marchewka


People also ask

Is Windows 10 device ID unique?

Each device in Windows has it's own unique identifier known as the Hardware ID. The Device ID is the identifier of the PC itself.

What is a computer unique identifier?

A unique identifier (UID) is a numeric or alphanumeric string that is associated with a single entity within a given system. UIDs make it possible to address that entity, so that it can be accessed and interacted with.


3 Answers

It seems that

var deviceInformation = new EasClientDeviceInformation();
string Id = deviceInformation.Id.ToString();

is doing the magic, refering to EasClientDeviceInformation it provides a unique Id.

The Id property represents the DeviceId using the GUID truncated from the first 16 bytes of the SHA256 hash of the MachineID, User SID, and Package Family Name where the MachineID uses the SID of the local users group.

BUT it only works for Windows Store Apps... so there have to be another solution.

like image 102
Jens Marchewka Avatar answered Oct 20 '22 07:10

Jens Marchewka


Update for Windows 1609 ("Anniversary Update")

See this Q&A for a much better way to get an ID.

Old info for older OS builds

You need to add a reference to the Desktop and / or Mobile SDKs to build against the Hardware Token. At runtime you should use the ApiInformation type to query if the API is present before using it (other device families like Xbox don't have it).

That said, many times when people ask for the device ID that's not actually the best solution for their problem -- are you sure you need to identify the physical device across its entire lifespan, even if ownership changes?

like image 20
Peter Torr - MSFT Avatar answered Oct 20 '22 06:10

Peter Torr - MSFT


EasClientDeviceInformation does not work for Windows 10 mobile. The device id is just the same for every phone (all our win10m customers gets registered with the same GUID) We need the id for sending push messages to the right phone.

like image 1
tobjak75 Avatar answered Oct 20 '22 08:10

tobjak75