You can use HardwareIdentification.GetPackageSpecificToken(null)
, see http://msdn.microsoft.com/en-us/library/windows/apps/jj553431.aspx
That function gives you a lot of information, that you can filter as you like. For example:
public static string GetMachineId()
{
var hardwareToken =
HardwareIdentification.GetPackageSpecificToken(null).Id.ToArray();
var count = hardwareToken.Length / 4;
ulong id = 0ul;
for (int i = 0; i < count; i++)
{
switch (BitConverter.ToUInt16(hardwareToken, i * 4))
{
case 1:
// processor
case 2:
// memory
case 9:
// system BIOS
id = (id << 12) ^ BitConverter.ToUInt16(hardwareToken, i * 4 + 2);
break;
}
}
return Convert.ToBase64String(BitConverter.GetBytes(id));
}
However, bear in mind that this function, and the underlying API, cannot guarantee absolute uniqueness across all the machines connected to the internet. You would typically combine this with information about the user.
Another option is to generate and store a GUID in local (non-roaming) storage, and use that as your machine id. Depending in you exact needs, this may be a better solution.
However, the ASHWID changes if the hardware profile of the device changes, such as when the user unplugs a USB Bluetooth adapter
. msdn.microsoft.com/en-us/library/windows/apps/jj553431.aspx – Ammamaria