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.
- First we check is the Product key is provided or not.
- If provided then Execute the main application.
- Otherwise check, software is blacklisted or not. *
- If black listed then asked for valid key if no key then terminate.
- If not blacklisted check first time execution or not.
- If first time execute then open a simple message & execute main application.
- 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.
- If user chose product key option then check that valid or not. If valid then show a confirm message, else not confirm.
- If 30 days over then show expired message & asked for Product key.
- 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,

Next time,

And few days latter,

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

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

If trial Version is expired,

If enter a Correct Product key,

Other wise it looks like,

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

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!

Potato PeterPosted Apr 5, 2022, 6:38 AM
How do you change the 15 day trial into 30 days?
Muhammad IlyasPosted Nov 19, 2019, 3:54 AM
If user uninstall application and then reinstall the trial restarted. (i have tried)
Muhammad IlyasPosted Nov 18, 2019, 7:18 AM
How to validate a product key for one year? i mean application stops working after one year
Anis KhanPosted Apr 16, 2019, 5:35 AM
Can u send Steps by step process of above code ya video link.
suresh dPosted Nov 1, 2018, 6:52 AM
Good article, Its very useful. Once trail period is over the user uninstall the application and reinstall again and use few more days its possible. Please explain
Azi SPosted Oct 23, 2018, 12:07 AM
What will write to the product key
Jagdish patelPosted Jan 27, 2018, 3:18 AM
Hi sir, Very GoodExplain. Its works , but what to write in product key
Basit AminPosted Dec 14, 2017, 5:18 AM
Where we build product key
Irfan CubosquarePosted Nov 11, 2017, 2:34 AM
Hello Sir, What is string path and what i should to change over their,
venkata rajeshPosted Apr 1, 2017, 5:42 AM
What is this string path = @"Software\Tanmay\Protection";
Amarkant SemwalPosted Dec 31, 2016, 4:43 AM
Please can you help me sir
Amarkant SemwalPosted Dec 31, 2016, 4:42 AM
Sir what is registry path help me
Madhv KushawahPosted Sep 12, 2016, 4:26 AM
If user change its date-time to back date-time, than trial will work or not?
Vinay SinghPosted Jun 9, 2016, 2:12 AM
Hi Good work. But plz let me know how we will create the create the product key and how it will be get validated. is user reset the registry then application will again increase the trial duration.
Risers RngPosted May 27, 2016, 3:41 AM
what is this string path = @"Software\Tanmay\Protection";
Risers RngPosted May 27, 2016, 2:05 AM
Thanks for this solution but if i want to create 4 Product Keys First 3 are for 30 day trial period & last one is for final product key then how could i achieve this? Please help me its urgent
Nitin PatilPosted May 11, 2016, 6:25 AM
what does it mean - string path = @"Software\Tanmay\Protection";
Nitin PatilPosted May 10, 2016, 7:17 AM
hey how can I use this for my application....can you explain me
Bhuvanesh MohankumarPosted May 10, 2016, 3:25 AM
Good Job
Xtreme DevelopersPosted Mar 11, 2016, 5:27 AM
its a good example but need to hide the registry location by just typing random string "34234adasd" bcoz if user find the info in registry and delete the keys software will work
saikat bhaduryPosted Oct 24, 2015, 1:24 AM
Thanks a lot...
roshan pillaiPosted Oct 16, 2015, 3:04 AM
Awesome...Thanks.
ChetannPosted Jul 14, 2015, 8:16 AM
gud work
Jerry 00Posted May 14, 2015, 3:28 PM
if 30 days trail period is over ,and user does not enter the product key. Instead clicks on "No", then too the main form is executed.
ketan chandpaPosted Feb 12, 2015, 6:19 AM
How to add the days for checking software is expired or not?
Mfwamba TshimangaPosted Jul 6, 2014, 8:46 PM
Hey, congratulation. Very simple and objective!
Zhivko VanchevPosted Jun 2, 2014, 3:55 AM
Thank you, it is very useful example!
chris lautschPosted Dec 27, 2013, 8:19 PM
Can you use the dll file in visual basic 2010?this is vary good i like it.
Aloya KotyaPosted Dec 9, 2013, 1:51 PM
plzzzzzz
Aloya KotyaPosted Dec 9, 2013, 1:46 PM
and how to give temporarily product key
Aloya KotyaPosted Dec 9, 2013, 1:44 PM
Very usefull Article....! Thank You Plz any body know tell me how to increase duration.
ketan italiyaPosted Oct 29, 2013, 1:57 AM
this is the superb example,bro. thanks
krishna pandeyPosted Sep 10, 2013, 4:40 AM
how can create Product Key
asima padhyPosted Jun 4, 2013, 1:32 AM
How can we do for a web application
romeland dela penaPosted Jan 2, 2013, 3:37 AM
ill try it dude... tnx anyway!
murugan muruganPosted Nov 26, 2012, 6:51 AM
thank you dude.it s very usefull for me.
Kashif RashidPosted Sep 1, 2012, 2:40 AM
gud
harun ahmedPosted Jun 15, 2012, 4:26 PM
Thank you very much for this post.Really very helpful for me.
Moti lalPosted May 2, 2012, 6:03 PM
how can we enter a Correct Product key in this application?
Ali nasirPosted Apr 24, 2012, 4:12 AM
Pleas describe that how I can embed this awesome secure application to make my project secured..... It's a very nice and simple code
Suyel SarafPosted Mar 20, 2011, 12:20 PM
The above example is very interesting and helpful too... Can u plz explain it in brief ??
Tanmay SarkarPosted Sep 8, 2010, 1:55 AM
A building always build step by step. If any body want to build keys for several users then there is a simple article http://www.c-sharpcorner.com/UploadFile/tanmayit08/3239/Default.aspx Thank you!
Vijay GillPosted Sep 5, 2010, 4:17 PM
No matter what complex path you try to create (as you have suggested in limitations), it can be found out with RegMon. 'As Product key is in main project, for several product key you should build it for several times.' - does that mean for 1000 copies of my software, I need 1000 builds? How does it scale up?