Original: http://blog.csdn.net/crow_n/article/details/51719144
Http://www.cnblogs.com/hanzhaoxin/archive/2013/01/04/2844191.html
The principle is that the software and the registration machine use the same algorithm to match the data. After registration, the data is written to the registry. A simple way to register a machine.
1, the realization of software
[CSharp] View Plain copy using system; using system.collections.generic; using System.Linq; using system.management; using system.text; using system.threading.tasks; namespace softwareregister { class SoftReg { /// <summary> /// get HDD serial number /// </summary > /// <returns></returns> public string getdiskserialnum () { & NBsp; managementclass mydisk = new managementclass ("Win32_ Networkadapterconfiguration "); managementobject disk = new managementobject ("win32_logicaldisk.deviceid=\" C:\ ""); disk. Get (); return disk. GetPropertyValue ("VolumeSerialNumber"). ToString (); } /// <summary> // / Get CPU serial number /// </summary> /// <returns></returns> &nbsP; public string getcpuserialnum () { string cpustr = ""; managementclass mycpu = new managementclass ("Win32_Processor"); ManagementObjectCollection Mycpucollention = mycpu. GetInstances (); foreach (managementobject var in mycpucollention) { cpustr = var. properties["Processorid"]. Value.tostring(); } return cpustr; } /// < summary> /// The first 24 digits of the CPU serial number and HDD serial number to do the machine code /// </summary> /// <returns></returns> public string getmachinenum () { string num = getcpuserialnum () + getdiskserialnum (); &Nbsp; string machinenum = num.substring (0,24);