This should work too, but I don't have Windows 8 to test with ...
private string GetHardwareId() { return BitConverter.ToString(Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null).Id.ToArray()); }
And if you call it more than once, you might want to paste it into Lazy<T>
private static Lazy<string> _hardwareId = new Lazy<string>(() => BitConverter.ToString(Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null).Id.ToArray()), true); public string HardwareId() { return _hardwareId.Value; }
Or just make it static if you know that it will always be called:
public static readonly string HardwareId = BitConverter.ToString(Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null).Id.ToArray()));
Chris gessler
source share