Make Your Application with Trial Version


Make Your Application with Trial Version

In this article we see how we assign trial period in our Application.

Most of the software has its own trial period. Few have installation time.

Here I describe the simplest way to make our product trial. We build a simple dll & call it from our application.

Features of this dll:

  • If user has no key then it works only for 30 days.
  • When user starts the app it asked if he/she interested to enter a product key or not.
  • If user changes the date then the software will not run until he/she enters a valid product key.

The algorithm is very simple.

  1. First we check is the Product key is provided or not.
  2. If provided then Execute the main application.
  3. Otherwise check, software is blacklisted or not. *
  4. If black listed then asked for valid key if no key then terminate.
  5. If not blacklisted check first time execution or not.
  6. If first time execute then open a simple message & execute main application.
  7. If not, check day duration if less than 30 days, then open a message that it is in trial period, user may enter Product key.
  8. If user chose product key option then check that valid or not. If valid then show a confirm message, else not confirm.
  9. If 30 days over then show expired message & asked for Product key.
  10. If provide valid Product key then open main application, Otherwise terminate application.
     

(*) blacklist: If user changes the system date then this checking marks the software as term blacklist. It has no other meaning. If it mark as blacklist then until providing the valid product Key It will not work.

The Code snippiest is,

In your main Application, add this code to Programm.CS

using SecureApp;

static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            string path = @"Software\Tanmay\Protection";
            Secure scr = new Secure();
            bool logic = scr.Algorithm("tanmay", path);
            if(logic ==true)
                Application.Run(new Form1());
        }

Here all the necessary information will save in Registry.

So you must provide a valid path, which will create this dll.

In this case the password is : tanmay,

Those two things are provided as,

bool logic = scr.Algorithm("tanmay", path);

The main code scr.Algorithm(,) is as follows,

public bool Algorithm(String appPassword, String pass)
        {
            globalPath = pass;
            bool chpass = checkPassword(appPassword);
            if (chpass == true) //execute
                return true;
            else
            {
                bool block = blackListCheck();
                if (block == false)
                {
                    string chinstall = checkfirstDate();
                    if (chinstall == "First")
                    {
                        firstTime();// installation date
                        DialogResult ds = MessageBox.Show("You are using trial Pack! Would you Like to Activate it Now!", "Product key", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        if (ds == DialogResult.Yes)
                        {
                            Form1 f1 = new Form1(appPassword, globalPath);
                            DialogResult ds1 = f1.ShowDialog();
                            if (ds1 == DialogResult.OK)
                                return true;
                            else
                                return false;
                        }
                        else
                            return true;
                    }
                    else
                    {
                        string status = dayDifPutPresent();
                        if (status == "Error")
                        {
                            blackList();
                            DialogResult ds = MessageBox.Show("Application Can't be loaded, Unauthorized Date Interrupt Occurred! Without activation it can't run! Would you like to activate it?", "Terminate Error-02", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                            if (ds == DialogResult.Yes)
                            {
                                Form1 f1 = new Form1(appPassword, globalPath);
                                DialogResult ds1 = f1.ShowDialog();
                                if (ds1 == DialogResult.OK)
                                    return true;
                                else
                                    return false;
                            }
                            else
                                return false;
                        }
                        else if (status == "Expired")
                        {
                            DialogResult ds = MessageBox.Show("The trial version is now expired! Would you Like to Activate it Now!", "Product key", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                            if (ds == DialogResult.Yes)
                            {
                                Form1 f1 = new Form1(appPassword, globalPath);
                                DialogResult ds1 = f1.ShowDialog();
                                if (ds1 == DialogResult.OK)
                                    return true;
                                else
                                    return false;
                            }
                            else
                                return false;
                        }
                        else // execute with how many day remaining
                        {
                            DialogResult ds = MessageBox.Show("You are using trial Pack, you have " + status + " days left to Activate! Would you Like to Activate it now!", "Product key", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                            if (ds == DialogResult.Yes)
                            {
                                Form1 f1 = new Form1(appPassword, globalPath);
                                DialogResult ds1 = f1.ShowDialog();
                                if (ds1 == DialogResult.OK)
                                    return true;
                                else
                                    return false;
                            }
                            else
                                return true;
                        }
                    }
                }
                else
                {
                    DialogResult ds = MessageBox.Show("Application Can't be loaded, Unauthorized Date Interrupt Occurred! Without activation it can't run! Would you like to activate it?", "Terminate Error-01", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    if (ds == DialogResult.Yes)
                    {
                        Form1 f1 = new Form1(appPassword, globalPath);
                        DialogResult ds1 = f1.ShowDialog();
                        if (ds1 == DialogResult.OK)
                            return true;
                        else
                            return false;
                    }
                    else
                        return false;
                    //return "BlackList";
                }
            }
        }


 

All other methods are in source code. So download full source code if you want to use it.

Screen Shorts:

When First time it will open,

trial1.JPG

Next time,

trial2.JPG

And few days latter,

trial3.JPG

If user Want to enter Product key then chose Yes Button & the screen will be,

trial4.JPG

If user interrupt in system date the Error Message will like,

trial5.JPG

If trial Version is expired,

trial6.JPG

If enter a Correct Product key,

trial7.JPG

Other wise it looks like,

trial8.JPG

Now in every time, the original application will start first, like the sample,

trial9.JPG

Limitation:

All the information is saved in Registry, so it can be found. You should create a complex path.

As Product key is in main project, for several product key you should build it for several times.

Few Words:

This article just shows a sample or can say an easiest way to make trial product.

It is built in Visual Studio 2010 & framework 3.5.

That's it.

Hope, it will help you!

Thank you!