I have a software installed on my clients’ PC, I give the license key to clients according to their CPU ID and Motherboard ID. This code is working correctly on most PCs but sometimes return incorrect value for CPU or M.B, for example:
CPU ID = “0000000000000000”
M.B = “” // empty string
string results = string.Empty;
string cpuID = string.Empty;
ManagementClass mc = new ManagementClass("win32_processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
cpuID += mo.Properties["processorID"].Value.ToString();
}
results += cpuID;
//get motherboard ID:
string mbID = string.Empty;
string query = "SELECT * FROM Win32_BaseBoard";
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach (ManagementObject info in searcher.Get())
{
mbID += info.GetPropertyValue("SerialNumber").ToString();
}
results += "\r\n" + mbID;
return results;
I’m in a hard situation because this issue is rare, I made about 100 licenses and this case happened 5 times only, it occurred on a client PC not on my PC, so trying a new code is really so hard. Any idea please? Or someone knows what is the possible reason. Thanks