C # Software registration and Registration (reference)

Source: Internet
Author: User

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);  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.