trial code help

Han_BFY

New member
Joined
Mar 17, 2011
Messages
1
Programming Experience
Beginner
Hi friends, Below is my trial code to run program for certain day.... but if user reverse the computer date the program can proceed to work... How to rectify this I need help from you guys... Thanks in advance Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim TimesLoaded As Integer = My.Settings.TimesRun Dim FirstRun As Date If TimesLoaded = 0 Then 'App has never run before, we need to save the FirstRun Date My.Settings.FirstRun = Now My.Settings.Save() End If FirstRun = My.Settings.FirstRun 'Tick up the counter TimesLoaded += 1 My.Settings.TimesRun = TimesLoaded My.Settings.Save() 'Did the Trial Period expire, or has the app ben run more times than allowed? Dim Expired As Boolean = CBool(TimesLoaded > Max_Times_Loaded OrElse DateDiff(DateInterval.Day, FirstRun, Now) >= 2) If Expired Then MsgBox("Sorry Times up") End If End Sub
 
Last edited:
There is no way to get an 'accurate' date from the computer side, the user will always be able to change it. You will either have to get the date/time from an external server or go by application uses. Another option is to simply limit the features of your application for the trial version (creating a demo instead of a trial).

Hope this helps
-Josh
 
Back
Top