[分享]用CPU+硬盘号作软件注册序列号
第一步,添加引用".COM"中选择Management组件.
第二步,取CPU序列号的代码
//记得开头要用这句引用
using System.Management;
//取CPU序列号
public String GetCpuID()
{
try
{
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
String strCpuID = null ;
foreach( ManagementObject mo in moc )
{
strCpuID = mo.Properties["ProcessorId"].Value.ToString();
break;
}
return strCpuID;
}
catch
{
return "";
}
}