Wednesday, September 5, 2012

Windows 8: Uniquely identifying a device

For a Windows 8 application I’m building, I needed a way to uniquely identify a user’s device. The best option I found was using the HardwareIdentification value. The only problem it has is that it can change if your system hardware changes(but that’s good enough for me Glimlach)

O yes, here is the code I used:

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);


Anonymous said...

Thank you! :)

Apparently, you and I are the only people on the Internet trying to do this in C#!

You solved my problem and now I'm very happy :)

Anonymous said...

How can I convert to guid?

Anonymous said...

How do we do this in Visual Basic?

mesteruh mesteruh said...

how add this code to winform app? Windows 7 OS