第一步。根據卷標,CPU序列號,生成機器碼
//獲得CPU的序列號
public static 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;
}
//生成機器碼
public static string getMNum()
{
string strNum = getCpu() + GetDiskVolumeSerialNumber();//獲得24位Cpu和硬盤序列號
string strMNum = strNum.Substring(0, 24);//從生成的字符串中取出前24個字符做為機器碼
return strMNum;
}
public static int[] intCode = new int[127];//存儲密鑰
public static int[] intNumber = new int[25];//存機器碼的Ascii值
public static char[] Charcode = new char[25];//存儲機器碼字
public static void setIntCode()//給數組賦值小于10的數
{
for (int i = 1; i < intCode.Length; i++)
{
intCode[i] = i % 9;
}
}
public static string getRNum()
{
setIntCode();//初始化127位數組
for (int i = 1; i < Charcode.Length; i++)//把機器碼存入數組中
{
Charcode[i] = Convert.ToChar(getMNum().Substring(i
主站蜘蛛池模板:
白城市|
怀化市|
通许县|
黄大仙区|
灵宝市|
江永县|
县级市|
滨州市|
鹤峰县|
中西区|
巨野县|
石泉县|
宁津县|
林周县|
云龙县|
郧西县|
杭州市|
鄂托克前旗|
绥棱县|
定安县|
神池县|
诏安县|
海伦市|
青州市|
阿克陶县|
库车县|
梨树县|
绿春县|
凉城县|
内乡县|
兴国县|
象山县|
桦川县|
临江市|
皮山县|
开封县|
南乐县|
卓尼县|
锦州市|
垫江县|
河曲县|