星期六

获取主板及硬盘序列号
代码
 1 public string getCode()
 2     {
 3       string str = "";
 4       try
 5       {
 6         ManagementClass c2 = new ManagementClass("Win32_BIOS");
 7         foreach (ManagementObject obj2 in c2.GetInstances())
 8         {
 9           str = obj2.Properties["Name"].Value.ToString() + obj2.Properties["Version"].Value.ToString();
10         }
11       }
12       catch (Exception)
13       {
14         str = "bios info is null.";
15       }
16       string str2 = "";
17       try
18       {
19         ManagementClass c3 = new ManagementClass("Win32_DiskDrive");
20         foreach (ManagementObject obj3 in c3.GetInstances())
21         {
22           if (obj3.Properties["Index"].Value.ToString() == "0")
23           {
24             str2 = obj3.Properties["Model"].Value.ToString() + obj3.Properties["Size"].Value.ToString();
25           }
26         }
27       }
28       catch (Exception)
29       {
30         str2 = "disk info is null.";
31       }
32       if (this.cdkey.Length == 12)
33       {
34         this.code = str + str2;
35         this.code = Math.Abs(this.code.GetHashCode()).ToString();
36         this.code = this.code.PadLeft(10'0');
37         this.code = this.code.Substring(37);
38         this.code = this.code + this.getSpCode(this.code);
39         this.code = this.cdkey + this.code;
40       }
41       else if (this.cdkey.Length == 0x10)
42       {
43         this.code = str + str2;
44         this.code = Math.Abs(this.code.GetHashCode()).ToString();
45         this.code = this.code.PadLeft(10'0');
46         this.cdkey = Math.Abs(this.cdkey.GetHashCode()).ToString();
47         this.cdkey = this.cdkey.PadLeft(10'0');
48         this.code = this.code + this.cdkey;
49       }
50       return this.code;
51     }

 

posted on 2010-03-09 11:34  星期六  阅读(370)  评论(0编辑  收藏  举报