David
David

Reputation: 475

Retrieving the serial number of a device using WinRT

We are working on an app that needs to know the serial number of the device it is running on. The app is for an insurance company with which the user is able to directly get insurance for the device. For the insurance policy the serial number is needed. Is it possible to retrieve the serial number of the device using the WinRT or any API that can be used in a metro style app?

Upvotes: 2

Views: 982

Answers (1)

Florian P
Florian P

Reputation: 21

I do not know if it exactly fits your need, but it is possible to uniquely identify a device (since Windows 8 RTM).

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];
    dataReader.ReadBytes(bytes);

    return BitConverter.ToString(bytes);
}  

Upvotes: 2

Related Questions