使用硬盘序列号和CPU序列号生成机器码
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = getCpu() GetDiskVolumeSerialNumber();//获得24位Cpu和硬盘序列号
string[] strid = new string[24];
for (int i = 0; i < 24; i )//把字符赋给数组
{
strid[i] = label1.Text.Substring(i, 1);
}
label1.Text = "";
Random rdid = new Random();
for (int i = 0; i < 24; i )//从数组随机抽取24个字符组成新的字符生成机器码
{
label1.Text = strid[rdid.Next(0, 24)];
}
}
//取得设备硬盘的卷标号
public string GetDiskVolumeSerialNumber()
{
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"d:\"");
disk.Get();
return disk.GetPropertyValue("VolumeSerialNumber").ToString();
}
//获得CPU的序列号
public string getCpu()
{
string strCpu = null;
ManagementClass myCpu = new ManagementClass("win32_Processor");
ManagementObjectCollection myCpuConnection = myCpu.GetInstances();
foreach (ManagementObject myObject in myCpuConnection)
{
strCpu = myObject.Properties["Processorid"].Value.ToString();
break;
}
return strCpu;
}
}
资源文件列表
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP.sln , 944
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP.suo , 36864
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/bin/Debug/GetMCodeByCPUAndYP.exe , 9728
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/bin/Debug/GetMCodeByCPUAndYP.pdb , 22016
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/bin/Debug/GetMCodeByCPUAndYP.vshost.exe , 14328
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/Form1.cs , 1960
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/Form1.designer.cs , 3559
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/Form1.resx , 5814
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/GetMCodeByCPUAndYP.csproj , 3829
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/obj/Debug/GetMCodeByCPUAndYP.csproj.FileListAbsolute.txt , 953
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/obj/Debug/GetMCodeByCPUAndYP.csproj.GenerateResource.Cache , 847
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/obj/Debug/GetMCodeByCPUAndYP.exe , 9728
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/obj/Debug/GetMCodeByCPUAndYP.Form1.resources , 180
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/obj/Debug/GetMCodeByCPUAndYP.pdb , 22016
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/obj/Debug/GetMCodeByCPUAndYP.Properties.Resources.resources , 180
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/Program.cs , 499
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/Properties/AssemblyInfo.cs , 1392
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/Properties/Resources.Designer.cs , 2886
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/Properties/Resources.resx , 5612
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/Properties/Settings.Designer.cs , 1103
╕∙╛▌CPU╙▓┼╠╗±╚í╗·╞≈┬δ/GetMCodeByCPUAndYP/Properties/Settings.settings , 249
