We're working hard on the next version of Developer Fusion. Let us know what you think
we should be up to!
Members
Technology Zones
Articles
Hosted By
Info
|
Rated
Read 18,492 times
Related Categories
Create a "Trial" Period
This fairly short piece of code allows the program to check whether a trial period of any length has expired, notifying the user how many days are left. The user is given the option to register the program or just not use it any more. It uses the VB registry setting functions. Encryption can be added when saving to the registry so that almost nobody at all can use the program for longer than the trial period.
Option Explicit
Private Const TRIAL_PERIOD_DAYS As Integer = 30
Private Function TrialPeriodDaysLeft(DaysTrial As Integer) As Integer
Dim DateStart As Date
DateStart = GetSetting(App.Title, "Trial Period", "Date Start", 0)
If DateStart = 0 Then
SaveSetting App.Title, "Trial Period", "Date Start", Date
Else
TrialPeriodDaysLeft = DateDiff("d", DateStart, Date) > DaysTrial
End If
End Function
Private Sub AppSetRegistered(Registered As Boolean)
SaveSetting App.Title, "Trial Period", "Registered", Registered
End Sub
Private Function AppRegistered() As Boolean
AppRegistered = GetSetting(App.Title, "Trial Period", "Registered", False)
End Function
Private Sub Form_Load()
If Not AppRegistered Then
Dim DaysLeft As Integer
DaysLeft = TrialPeriodDaysLeft(TRIAL_PERIOD_DAYS)
If DaysLeft < 0 Then
If MsgBox("The trial period for " & App.Title & " has expired." & vbCrLf & _
"Would you like to register to continue using this program?", vbQuestion + vbYesNo) = vbYes Then
' Open up order form here
' Use: 'AppSetRegistered True' to register program
Else
' Exit your program here
End If
Else
MsgBox "You have " & DaysLeft & " " & IIf(DaysLeft = 1, "day left", "days left") & " to use this program.", vbInformation
End If
End If
End Sub
Currently programs in VB, QBasic, ASP, PHP, SQL, HTML, CSS, VBScript and some Java/JavaScript. Learning VB.NET.
Comments
-
Posted by Phred on 08 Dec 2005
Forget the encryption all they have to do is delete this registry key and the trial period starts over again. -
Posted by shortbus on 04 May 2004
I found a free program that you can use to create trials. It's at http://www.softwarekey.com/swk_products/trial_creator/. It's real nice software and its free!!!
Posted by domdm on 28 Feb 2004
well said!!!
Posted by alexreg on 28 Feb 2004
thank you D :)
it's easy to add encyption. add MD5 or even XOR and if it isn't perfectly encypted - if the user tries to change it, then it will not allow you to use the program. i can't provide ever...
erm no when you use the inbuild Get/SaveSetting functions it gets/saves them to:
HKEY_CURRENT_USER\Software\VB and VBA Program Settings\
furthermore if the key doesnt exist the "default" value is ...
|
Search
Code Samples
New Members
|