C # Implementation of registration of the validity period of simple software [original]

Source: Internet
Author: User

◆ Requirements:

The company has not been able to control the time of use of the products developed for a long time, or write the date limit to death.ProgramIt is inconvenient to compile a new program and send it to the customer every time. Therefore, the company asked me to write a module with the following requirements:

1. No matter which newly developed program calls this module, the validity period can be controlled.

2. After the software expires, we need to provide a valid registration code for the software to continue to use.

3. The customer can still control the time when the computer is modified or the software is moved to another computer.

4. If the registry is used, users cannot modify the Registry to continue using the registry after they know the registry.

5. control methods should not be too complex

◆ Analysis:

1,At that time, my first reaction was DLL, so I used the DLL method.

2. Create a registration machine.

3. I started to use the network time verification method, but the customer's computer is not necessarily connected to the Internet, so the network time is not used.

4. If the registry is used, reinstalling the system or obtaining other computer software still cannot be controlled, so you simply do not need the registry.

5. To register a function, you only need to reference the DLL and modify the program. CS file as follows. This is simple enough.

 
Regdll. regclass Reg = new regdll. regclass (system. io. file. getlastwritetime (system. reflection. assembly. getassembly (typeof (form1 )). location ). tow.datestring (); If (Reg. mistart_infos () & reg. miend_infos () {application. enablevisualstyles (); // application. setcompatibletextrenderingdefault (true); // this sentence should be commented out, because only one sentence can appear in a program, and there is already one sentence in the DLL, so the application should be commented out here. run (New form1 ();} else {application. exit ();}

Implementation ideas:

In fact, it is quite simple. I use two files to record the software registration time (the secret file mentioned below) and the expiration time (the registration file mentioned below ), these two files can be used in Notepad. Files are mandatory as necessary files of the software and cannot run the software if they are missing. Of course, files can be encrypted for higher security, but I have not done it here.

The functions implemented by the DLL module are as follows:

1. Check whether the secret file exists (Eng. K)
1. If it exists, the ciphertext is read. If the ciphertext is null, the compilation date of the program is written. (After this module is called, the software needs to be registered once for the first operation)
2. If the ciphertext is not empty, it is compared with the current computer time to verify the validity of the computer time. If the ciphertext is valid, the computer time is written into the secret file.

3. The validity of the time here means that the computer time cannot be less than the software registration time, which has been verified.

2. Check whether the registration file exists (Engi. p)
1. If yes, the software validity period in the ciphertext is read.
2. If the ciphertext validity period is null and the confidential file information is correct, the registration code is generated and the valid date is written.

3. Check whether the current date is in the date of the two files. If yes, the software is valid. Otherwise, the software's registration code is invalid and you need to re-register the valid registration code.

Iii. Registration machine implementation

1. Of course, the registration code is generated based on the date.

2. Send the registration code to the customer for registration. As to whether the registration code is valid, it is what the DLL should do.

4. There is a vulnerability in this method. If the customer knows the registration principle, he can crack it intelligently. Therefore, he must not disclose O (∩ _ ∩) O ~

◆ Source code

Source code self-feeling write pretty, here I don't provide, but provide my DLL file, registration machine and example project: http://files.cnblogs.com/linyc/REGDLL.rar

PS: If you want to see the source code, you can use the decompilation software. After reading the source code, you will know that you just use the "trick". You are welcome to decompile it ~ Do you have any suggestions ~

Statement: This software is only used for communication technology and cannot be used for commercial purposes. I shall not be liable for any legal issues or other liabilities arising therefrom.

Reprinted please indicate the source: http://www.cnblogs.com/linyc/archive/2011/03/26/1996397.html

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.