Click here to Skip to main content
15,891,409 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear friends,

I have Developed a Windows application using C# code. Now I need to apply Expiry date, that means I need to create trial version for the 1st time user, and The application must close after the expire date.

Please anyone help me for this problem.

Thanks in Advance.
Posted
Comments
BillWoodruff 31-Oct-14 5:37am    
Start here:

http://www.codeproject.com/search.aspx?q=trial+version&doctypeid=1

If you know the expiration date in the application, one idea is to implement a logic like the next one.

In your main form Load event first hide the main form (by using this.Hide()), then check the current date (by using DateTime.Now property) and compare it with the expiration date (by using DateTime.CompareTo() method); There are 2 possibilities:
1.If the current date is higher then the expiration date you could notify the user about this (by using MessageBox.Show() method) then close the application (by using this.Close()).
2.Otherwise show the current form (by using this.Show() method).
 
Share this answer
 
v2
Comments
Member 11140188 31-Oct-14 6:19am    
Thank you for the helpfull Information.:)

and

I've code like this for my project, but it is not working, Can you find where I did the mistake..??

[CODE]

protected void Page_Load(object sender, System.EventArgs e)
{
this.Hide();
int period = 21; // trial period
string keyName = "/Datefile.txt";
long ticks = DateTime.Today.Ticks;

RegistryKey rootKey = Registry.CurrentUser;
RegistryKey regKey = rootKey.OpenSubKey(keyName);
if (regKey == null) // first time app has been used
{
regKey = rootKey.CreateSubKey(keyName);
long expiry = DateTime.Today.AddDays(period).Ticks;
regKey.SetValue("expiry", expiry, RegistryValueKind.QWord);
regKey.Close();
}
else
{
long expiry = (long)regKey.GetValue("expiry");
regKey.Close();
long today = DateTime.Today.Ticks;
if (today > expiry)
{
MessageBox.Show("Sorry your Software Expired...!!!");
this.Close();
}
else
this.show();
}
}

[ENDCODE]
Raul Iloc 31-Oct-14 7:26am    
At first look, the logic from your code looks OK.
Can you give me details about what is not working like you expected?
Member 11140188 31-Oct-14 7:49am    
I applied this code to mainForm in my project, the project still runs even though after expiry date.
It is not closing the application or showing any Message box after expiry date.
Raul Iloc 31-Oct-14 7:59am    
Some questions/causes:
1.Did you link "Load" event correctly with your main form?
2.Are the values saved in Registry only at the first usage?
3.I saw in your code that you have added a number of days, so this means that you cannot test it today!? You should use minutes for your first tests!

You should debug you application and see where is the problem!
sir please see the below link which contains a working expiry date application

Application Trial Maker[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900