Click here to Skip to main content
14,699,869 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I have generate the license. there is two dates for check the license is valid or not.if i have 5 days remaining to expire the license that time i change the system date ago 5 days then the license expired after 10 days. But i want 5 days remining output. not a 10 days remining.
Posted
Updated 1-May-11 21:23pm
v3
Comments
   
Next time please spell-check and format the question by yourself. Also, use correct capitalization. Not doing so is simply impolite.
--SA
   
Not a question.
--SA
Rajesh Anuhya 2-May-11 1:37am
   
Not Clear
Ankit Rajput 2-May-11 1:37am
   
Then what is the problem
vrushali katkade 2-May-11 2:46am
   
but how can i check the system date is changed & if i got the last run date then how can i calculate the dates remining to expire license.
fcronin 19-May-11 18:38pm
   
When does the license expire? 5 days after the first use? x Days after installation? You need more detail and clarity in what you are trying to do exactly.

With the type System.DateTime, you can apply operators ">", "<", ">=", "<=" to see which time is sooner and subtraction operator ("-") which returns System.TimeSpan. It should help you to solve the problem.

—SA
   
Hi,

You need to store Last Run Date to Registry or any where else from where you can easily read and write the data.
Now if somebody change the date then you can check the date range.

Case 1:
If somebody changes the date to back.
Now you have last run date now it get newer than Current date.
in this case, you can expire the license or anything you want to do.

Case 2: If somebody forward the date then automatically the same thing will happen.

Regards
AR
   
Comments
snorkie 19-May-11 20:37pm
   
You need to use caution with this approach to account for a change in time zones. If a user travels several time zones away, you could incorrectly invalidate a license with this method. I like your approach, but maybe consider a 30 hour window before disabling the license.

Along these lines, it is possible to keep track of how long the program has been in use and compare that with dates to ensure that the time does not roll back too far.
use this for get difference between time

PreDate dateTime = "12/12/2011";
DateTime Todayday = (System.DateTime.Now).ToShortDateString();

Check Time equal
Todayday = PreDate 

get Difference
Todayday > PreDate ;
   

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