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, 2:38 AM EDT
How do you change the 15 day trial into 30 days?
Muhammad IlyasPosted Nov 18, 2019, 10:54 PM EST
If user uninstall application and then reinstall the trial restarted. (i have tried)
Muhammad IlyasPosted Nov 18, 2019, 2:18 AM EST
How to validate a product key for one year? i mean application stops working after one year
Anis KhanPosted Apr 16, 2019, 1:35 AM EDT
Can u send Steps by step process of above code ya video link.
suresh dPosted Nov 1, 2018, 2:52 AM EDT
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 22, 2018, 8:07 PM EDT
What will write to the product key
Jagdish patelPosted Jan 26, 2018, 10:18 PM EST
Hi sir, Very GoodExplain. Its works , but what to write in product key
Basit AminPosted Dec 14, 2017, 12:18 AM EST
Where we build product key
Irfan CubosquarePosted Nov 10, 2017, 9:34 PM EST
Hello Sir, What is string path and what i should to change over their,
venkata rajeshPosted Apr 1, 2017, 1:42 AM EDT
What is this string path = @"Software\Tanmay\Protection";
Amarkant SemwalPosted Dec 30, 2016, 11:43 PM EST
Please can you help me sir
Amarkant SemwalPosted Dec 30, 2016, 11:42 PM EST
Sir what is registry path help me
Madhv KushawahPosted Sep 12, 2016, 12:26 AM EDT
If user change its date-time to back date-time, than trial will work or not?
Vinay SinghPosted Jun 8, 2016, 10:12 PM EDT
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 26, 2016, 11:41 PM EDT
what is this string path = @"Software\Tanmay\Protection";
Risers RngPosted May 26, 2016, 10:05 PM EDT
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, 2:25 AM EDT
what does it mean - string path = @"Software\Tanmay\Protection";
Nitin PatilPosted May 10, 2016, 3:17 AM EDT
hey how can I use this for my application....can you explain me
Bhuvanesh MohankumarPosted May 9, 2016, 11:25 PM EDT
Good Job
Xtreme DevelopersPosted Mar 11, 2016, 12:27 AM EST
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 23, 2015, 9:24 PM EDT
Thanks a lot...
roshan pillaiPosted Oct 15, 2015, 11:04 PM EDT
Awesome...Thanks.
ChetannPosted Jul 14, 2015, 4:16 AM EDT
gud work
Jerry 00Posted May 14, 2015, 11:28 AM EDT
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, 1:19 AM EST
How to add the days for checking software is expired or not?
Mfwamba TshimangaPosted Jul 6, 2014, 4:46 PM EDT
Hey, congratulation. Very simple and objective!
Zhivko VanchevPosted Jun 1, 2014, 11:55 PM EDT
Thank you, it is very useful example!
chris lautschPosted Dec 27, 2013, 3:19 PM EST
Can you use the dll file in visual basic 2010?this is vary good i like it.
Aloya KotyaPosted Dec 9, 2013, 8:51 AM EST
plzzzzzz
Aloya KotyaPosted Dec 9, 2013, 8:46 AM EST
and how to give temporarily product key
Aloya KotyaPosted Dec 9, 2013, 8:44 AM EST
Very usefull Article....! Thank You Plz any body know tell me how to increase duration.
ketan italiyaPosted Oct 28, 2013, 9:57 PM EDT
this is the superb example,bro. thanks
krishna pandeyPosted Sep 10, 2013, 12:40 AM EDT
how can create Product Key
asima padhyPosted Jun 3, 2013, 9:32 PM EDT
How can we do for a web application
romeland dela penaPosted Jan 1, 2013, 10:37 PM EST
ill try it dude... tnx anyway!
murugan muruganPosted Nov 26, 2012, 1:51 AM EST
thank you dude.it s very usefull for me.
Kashif RashidPosted Aug 31, 2012, 10:40 PM EDT
gud
harun ahmedPosted Jun 15, 2012, 12:26 PM EDT
Thank you very much for this post.Really very helpful for me.
Moti lalPosted May 2, 2012, 2:03 PM EDT
how can we enter a Correct Product key in this application?
Ali nasirPosted Apr 24, 2012, 12:12 AM EDT
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, 8:20 AM EDT
The above example is very interesting and helpful too... Can u plz explain it in brief ??
Tanmay SarkarPosted Sep 7, 2010, 9:55 PM EDT
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, 12:17 PM EDT
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?