How to generate a System( PC/Laptop) Hardware unique ID in C#?
Please Note: The configuration is same for all the systems.
How to generate a System( PC/Laptop) Hardware unique ID in C#?
Please Note: The configuration is same for all the systems.
I guess instead of the MAC address as it's based on the peripheral which can be changed, you can use the Processor & Motherboard id to identify the system as they will be only changed when it's damaged and creates a new system instead when changed
Func<string> SystemId = () =>
{
ManagementObjectCollection mbsList = null;
ManagementObjectSearcher mbs = new ManagementObjectSearcher("Select * From Win32_processor");
mbsList = mbs.Get();
string id = "";
foreach (ManagementObject mo in mbsList)
{
id = mo["ProcessorID"].ToString();
}
ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_BaseBoard");
ManagementObjectCollection moc = mos.Get();
string motherBoard = "";
foreach (ManagementObject mo in moc)
{
motherBoard = (string)mo["SerialNumber"];
}
string uniqueSystemId = id + motherBoard;
return uniqueSystemId;
};
Console.WriteLine(SystemId());
Even processor can be updated so that can be ignored + i got to know even Microsoft used to have the motherboard id to identify/activate windows.
Generally one of the most reliable approaches is to see if you can't grab the MAC address of a network card. Generally these are unique (unless you also configured all your MAC addresses to be the same in which case you will have bigger problems :)) But I second the earlier comment. If this is for copy protection don't do it. Users will be frustrated when they switch they network cards or retire their PC to move to more recent hardware.
You can generate a GUID not programmatically by using "Microsoft Windows SDK" tool "GUID Generator" (guidgen.exe). This tool has a different ways to represent a generated GUID, so you can further use it right in your application.