Implementing a Rudimentary Count Based Trial Version Plugin for Windows Applications

This tip describes a very rudimentary approach to implement a trial version of an application that will open for some predefined number of times.


Many a times, we want to demonstrate our application with full functionality to someone. While doing so, there is a risk of that application being used at the other end. This small tip describes a very quick way of implementing a Trial version in an application so that the application can only be opened for some limited number of times.

The approach defined in this article is very rudimentary and if it is used as is, then expert user can circumvent this version checking (full/trial) with very little effort. Perhaps using this approach in conjunction with encryption/decryption and little bit customization of logic will make it more robust for commercial use.

Note: This plugin uses a registry component found at CodeProject here.

Using the Code

What we are doing here is we are keeping a track of number of times the application has been run in Windows registry. We will check for the number of times the application has been opened. If the user is allowed to open the application, we will let him run the application and increase the count in the registry. If the number of count increases the acceptable runs in trial version, then we will not start the application.

If the user chooses to make this application a full version, then there is a separate registry entry. A simple code to change the registry value will convert the application to full version without the user needing to install this application again.

Here is the simple class that is handing this logic:

To use this component, we will have put a check at the application start up as:

The application will only run for 5 times in this particular case.

Points of Interest

This small code facilitates having a trial version for any Windows application. However if the registry editing is not allowed on a user machine, then this approach will not work. Then we will have to keep a separate configuration file keeping track of this information.

There is a lot of scope for improvement in this application. We can have features like encryption/decryption, custom logic instead of counts, having some particular key written while updating to full version to make this more robust.

Also, with some changes, we can easily change this plugin to have a time based trial version. We just have to track time instead of count in that case.

Note: The core of this approach is the class handling registry editing which can be found here.

Download the sample code for this article: TrialModePlugin