首页 新闻 会员 周边

C#winform的文本框显示注册码问题

0
悬赏园豆:30 [已关闭问题] 关闭于 2014-06-26 16:54

public static string GetDiskVolumeSerialNumber()
{
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"d:\"");
disk.Get();
return disk.GetPropertyValue("VolumeSerialNumber").ToString();
}

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();
string strMNum = strNum.Substring(0, 24);
return strMNum;
}
public static int[] intCode = new int[127];
public static int[] intNumber = new int[25];
public static char[] Charcode = new char[25];
public static void setIntCode()
{
for (int i = 1; i < intCode.Length; i++)
{
intCode[i] = i % 9;
}
}

 

public static string getRNum()
{
setIntCode();
for (int i = 1; i < Charcode.Length; i++)
{
Charcode[i] = Convert.ToChar(getMNum().Substring(i - 1, 1));
}
for (int j = 1; j < intNumber.Length; j++)
{
intNumber[j] = intCode[Convert.ToInt32(Charcode[j])] + Convert.ToInt32(Charcode[j]);
}
string strAsciiName = "";
for (int j = 1; j < intNumber.Length; j++)
{
if (intNumber[j] >= 48 && intNumber[j] <= 57)
{
strAsciiName += Convert.ToChar(intNumber[j]).ToString();
}
else if (intNumber[j] >= 65 && intNumber[j] <= 90)
{
strAsciiName += Convert.ToChar(intNumber[j]).ToString();
}
else if (intNumber[j] >= 97 && intNumber[j] <= 122)
{
strAsciiName += Convert.ToChar(intNumber[j]).ToString();
}

{
if (intNumber[j] > 122)
{
strAsciiName += Convert.ToChar(intNumber[j] - 10).ToString();
}
else
{
strAsciiName += Convert.ToChar(intNumber[j] - 9).ToString();
}
}
}
return strAsciiName;
}

 

这是我在网上找的注册码算法,但是不能在textbox1里面显示出来,用catch能把他显示出来,但是我不会用,求大神帮忙添加一下代码,谢谢

zerofeng的主页 zerofeng | 初学一级 | 园豆:5
提问于:2014-06-20 22:47
< >
分享
所有回答(1)
0

不是俺打击你,就你这样,还需要注册码作甚?

爱编程的大叔 | 园豆:30839 (高人七级) | 2014-06-20 22:57

谁没有新手的时候,我是刚学,想弄个玩玩,然后继续探究

支持(0) 反对(0) zerofeng | 园豆:5 (初学一级) | 2014-06-20 23:05
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册