Use C + + Builder to Set program usage time

Source: Internet
Author: User

At present, many applications have features that are free of charge within certain limits, which can effectively limit the use of illegal users, while also allowing legitimate users to fully understand the advantages and disadvantages of the software on the basis of the decision to buy. This article says that the method to implement this function is the protection method. The use of protection methods, based on the protection of genuine software, not only expands the scope of software use effectively, but also provides users with the opportunity to make a full choice.

Protection methods

This article describes 4 kinds of protection methods that are implemented using C + + Builder:

Use the registry to limit the number of days used by the program, such as limiting the use of 30 days;

Use the registry to limit the number of times a program is used, such as limiting the use of 45 times;

Set the deadline for the use of the program, such as the date of August 31, 2001;

Limit the time that you use each time the program is used, such as allowing 50 minutes at a time.

These protection methods can be used either individually or several simultaneous uses to achieve comprehensive protection.

Programming Ideas

1. Method 1 and Method 2

In the OnCreate event procedure for the main form of the program, define the registry Tregistry class object pointer Reg:

Tregistry *reg = new Tregistry;

Locate the registry root key by its properties Rootkey, such as:

Reg->rootkey = HKEY_USERS;

You can choose according to your needs

Using the Openkey method, open a custom primary key under the root key, for example:

Reg->openkey (". Default\\myprogram\\records ", false)

If the primary key does not exist (that is, the first time this program is run), you need to use the CreateKey () method to create the primary key and open it, write the subkey and the key values below (see Figure 1):

Count key to record the number of times the program is running

reg->writeinteger ("Count", 1);

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.