有时自己写的.NET软件或编译成DLL的ASP.NET不想让人随便用,可以在代码中加上你将使用的那台电脑的CPU序列号验证,以下就是读取CPU序列号的代码,记得using System.Management;
public static string getCPUID()
{
string cpuInfo = "";//cpu序列号
ManagementClass cimobject = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = cimobject.GetInstances();
foreach(ManagementObject mo in moc)
{
cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
}
return cpuInfo;
}