how can get device hardware info and generate a unique value with combining them ? for example i want a generate a unique code with (CPU serial number + ram serial number + ethernet mac address or etc) so how can i get CPU or Ram serial number in UWP ?
Asked
Active
Viewed 1,242 times
0
-
3why not use the method already provided to get a `SystemIdentificationInfo` object? https://learn.microsoft.com/en-us/uwp/api/windows.system.profile.systemidentification – Claies Dec 27 '17 at 04:39
-
I don't think you can get this information in a UWP app, i think you need to reevaluate the problem – TheGeneral Dec 27 '17 at 05:05
-
@Saruman, that API is specifically designed for UWP. Also, see [this Question & Answer](https://stackoverflow.com/questions/40387615/how-to-get-unique-device-ids-on-windows-10-anniversary-update) – Peter Torr - MSFT Dec 27 '17 at 07:06
-
@PeterTorr-MSFT i use `SystemIdentificationInfo` with Registery source but when the device is reset the Id changed! – Parsa Karami Dec 27 '17 at 07:30
-
Did you try any of the other sources? You can get MAC address if needed. – Peter Torr - MSFT Dec 27 '17 at 07:36
2 Answers
2
I find HardwareIdentification class in Windows.System.Profile namespace for generate UniqueID.
var token = HardwareIdentification.GetPackageSpecificToken(null);
using (DataReader reader = DataReader.FromBuffer(token.Id))
{
byte[] bytes = new byte[token.Id.Length];
reader.ReadBytes(bytes);
string uniqueCode = Encoding.ASCII.GetString(bytes);
}
For more information you can see Microsoft Document
To do that make sure you enable TPM on your target device, for enabling TPM you must installed it from TPM Configuration Tab in Windows device portal.
Tips : Raspberry pi doesn`t have any internal TPM so you must select Software TPM Emulator (NoSecurity) then install it, for Intel minnow board max and qualcomm dragonboard you can choose other options. after set and install TPM the device reboot, when it boot again the generated code which you can see on top always be unique.

Parsa Karami
- 702
- 1
- 8
- 30
-2
This is not a complete answer but, You can find CPU serial number by using following code,
string cpuInfo = string.Empty;
ManagementClass mc = new ManagementClass("win32_processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
cpuInfo = mo.Properties["processorID"].Value.ToString();
break;
}

TheGeneral
- 79,002
- 9
- 103
- 141

programtreasures
- 4,250
- 1
- 10
- 29