SIGN UP MEMBER LOGIN:    
ARTICLE

Make Your Application with Trial Version

Posted by Tanmay Sarkar Articles | C# Language September 04, 2010
In this article we see how we assign trial period in our Application.
Reader Level:

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!

Login to add your contents and source code to this article
share this article :
post comment
 

how can we enter a Correct Product key in this application?

Posted by Moti lal May 02, 2012

Pleas describe that how I can embed this awesome secure application to make my project secured..... It's a very nice and simple code

Posted by Ali nasir Apr 24, 2012

Nice article. it can b possible that enter key is valid for a period of time for ex period of 6 month then again you have to renew the product key. how to achieve this task.

Posted by M B Mar 17, 2012

Thanks Suyel, what type of explanation you need!

Posted by Tanmay Sarkar Mar 21, 2011

The above example is very interesting and helpful too... Can u plz explain it in brief ??

Posted by Suyel Saraf Mar 20, 2011
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Nevron Gauge for SharePoint
Become a Sponsor