usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Management;usingUtility;usingExdatacontrol;usingSystem.Collections;usingMicrosoft.Win32;namespacemytool{ Public classSoftreg {/// <summary> ///get the Hard disk volume label/// </summary> /// <returns></returns> Public Static stringGetdiskvolumeserialnumber () {ManagementClass mc=NewManagementClass ("Win32_NetworkAdapterConfiguration"); ManagementObject Disk=NewManagementObject ("win32_logicaldisk.deviceid=\ "c \""); Disk. Get (); returnDisk. GetPropertyValue ("VolumeSerialNumber"). ToString (); } /// <summary> ///Get CPU Serial number/// </summary> /// <returns></returns> Public Static stringgetcpu () {stringSTRCPU =NULL; ManagementClass mycpu=NewManagementClass ("Win32_Processor"); Managementobjectcollection mycpucollection=mycpu.getinstances (); foreach(ManagementObject MyObjectinchmycpucollection) {STRCPU= myobject.properties["Processorid"]. Value.tostring (); } returnstrcpu; } /// <summary> ///Generate machine code/// </summary> /// <returns></returns> Public Static stringGetmnum () {stringStrnum = GETCPU () +Getdiskvolumeserialnumber (); stringStrmnum = strnum.substring (0, -);//intercept the first 24 bits as machine code returnStrmnum; } Public Static int[] Intcode =New int[127];//Store Key Public Static Char[] CharCode =New Char[ -];//storing ASCII code Public Static int[] intnumber =New int[ -];//storing ASCII code values//initializing the key Public Static voidSetintcode () { for(inti =1; i < intcode.length; i++) {Intcode[i]= i%9; } } /// <summary> ///Generate registration Code/// </summary> /// <returns></returns> Public Static stringGetrnum () {setintcode (); stringStrmnum =Getmnum (); for(inti =1; i < charcode.length; i++)//Storage Machine Code{Charcode[i]= Convert.tochar (strmnum.substring (i-1,1)); } for(intj =1; J < Intnumber.length; J + +)//Changing the ASCII code value{Intnumber[j]= Convert.ToInt32 (Charcode[j]) +Intcode[convert.toint32 (Charcode[j]); } stringStrasciiname ="";//Registration Code for(intK =1; K < Intnumber.length; k++)//Generate registration Code { if((Intnumber[k] >= -&& Intnumber[k] <= $) || (Intnumber[k] >= $&&Intnumber[k]<= -) || (Intnumber[k] >= the&& Intnumber[k] <=122))//Judging if between 0-9, A-Z, a-Z{strasciiname+=Convert.tochar (Intnumber[k]). ToString (); } Else if(Intnumber[k] >122)//Judging if greater than Z{strasciiname+ = Convert.tochar (Intnumber[k]-Ten). ToString (); } Else{strasciiname+ = Convert.tochar (Intnumber[k]-9). ToString (); } } stringStrencrypt = Utility.DESEncrypt.Encrypt (strasciiname);//Encrypt returnStrencrypt; } /// <summary> ///Generate trial Registration code (take the registration code, the first n bits are changed to the current date)/// </summary> /// <returns></returns> Public Static stringGetbnum (exdatacontrol.exdatacenter DC) {stringStrdecrypt = Utility.DESEncrypt.Decrypt (Getrnum ());//first decrypt the registration code stringCurrentdatetime = Dc.getserverdatetime (). Substring (0,Ten); Strdecrypt= Strdecrypt.substring (Ten, Strdecrypt.length-Ten); stringstrkey = Currentdatetime + strdecrypt;//10-bit date + 14 digits after registration code stringStrencrypt = Utility.DESEncrypt.Encrypt (strkey);//Encrypt returnStrencrypt; } }}