6
I have a system to control and issue electronic license registration files, so I have control of how many machines my software can run. My teacher advised me to use the CPUID processor to validate and generate a license file (get the CPUID
and make a calculation on top of it, so the result would be unique to each processor) and the validation would be made at the time of installation, the requests would be made to the server that would request the CPUID
from the machine and return the license file.
Are there other ways to do this license registration control? Is there an API or feature? And how can the implementation be done?
Here follows my basic prototype that gets the CPUID
and performs a calculation. There are two functions string getCPUID()
and double CalculaCpuId(string cpuid)
is the basis for generating the electronic license record file.
Function getCPUID
:
private string getCPUID()
{
String cpuid = "";
try
{
ManagementObjectSearcher mbs = new ManagementObjectSearcher("Select ProcessorID From Win32_processor");
ManagementObjectCollection mbsList = mbs.Get();
foreach (ManagementObject mo in mbsList)
{
cpuid = mo["ProcessorID"].ToString();
}
return cpuid;
}
catch (Exception) { return cpuid; }
}
Function CalculaCpuId
:
private double CalculaCpuId(string cpuid)
{
if (string.IsNullOrEmpty(cpuid))
return 0;
double resultado = 0;
int soma = 0;
string digito;
for (int i = 0; i < cpuid.Length; i++)
{
digito = cpuid[i].ToString();
soma += Convert.ToInt32(digito, 16);
}
resultado = (soma / ((Math.Pow(2, 2)) + 4));
return resultado;
}
I am using Visual Studio to develop my system that needs license registration control.
A simple method that I have successfully used to limit machines that can run software is the "hardlock" (gives a googlada). Other methods I’ve used involve using a license manager server - either on the client’s network or in the cloud (depending on the constraints of the client’s environment); or a simple counter of simultaneous access to the system’s application server (if there is an application server; also, if the server allows farm, you have to worry about the centralized count of accesses).
– Caffé