思路是用加密程序 对硬盘号,cpu号和MAC号取出字符串并加密 产生一个序列号
每次程序启动后重新产生这个序列号并比对,如果一致则验证通过
using System;
using System.Collections.Generic;
using
System.IO;
using System.Management;
using System.Text;
using
System.Management.Instrumentation;
static string GetDeviceNumber()
{
string deviceinfo = "";
string cpuInfo = "";
//cpu序列号
ManagementClass cimobject = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = cimobject.GetInstances();
foreach (ManagementObject mo in moc)
{
cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
deviceinfo = deviceinfo + cpuInfo.ToString();
}
//获取网卡硬件地址
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc2 = mc.GetInstances();
foreach (ManagementObject mo in moc2)
{
if ((bool)mo["IPEnabled"] == true)
deviceinfo = deviceinfo + mo["MacAddress"].ToString();
mo.Dispose();
}
return deviceinfo;
}
时间: 2024-10-09 20:39:23