Library code snippets
Create a "Trial" Period
By Alex , published on 14 Dec 2003
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
Related articles
Related discussion
-
Run-time error '91'
by converter2009 (1 replies)
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
Forget the encryption all they have to do is delete this registry key and the trial period starts over again.
I found a free program that you can use to create trials. It's at http://www.softwarekey.com/swkproducts/trialcreator/. It's real nice software and its free!!!
well said!!!
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 everything....
though i know encyption is needed.
erm no when you use the inbuild Get/SaveSetting functions it gets/saves them to:
HKEYCURRENTUSER\Software\VB and VBA Program Settings\
furthermore if the key doesnt exist the "default" value is parsed back, this avoids this issue, if the key doest exist when you save it then it is created, so essentially you cannot go wrong UNLESS you have no privalleges to get to the HKEYLOCALMACHINE or HKEY_* hives set by your adminstrator...
about the submission, it misses some very important things to kepe in mind, you should think more about protecting your "validating" code... with msgboxes all over the place we can easily see where this code fragement is and "fiix" it so the validation is rendered useless... anyhow that talk is for another day...
phracker.....
if without the encrypt, we jz need to modify the register key
then every thing will become free version...
if with encryption, then must depend on the algorithm...
but we stil can use the softice to check the runtime algorithm...
How hard would this be to hack!
u was wrong man, Alex cant jz include the encrypt code for u man
if alex include it, i think ur program will very very easy crack by alex
so dun think alex make this mistake, he jz left the part for u, so that when ur software
been crack, dun jz say that alex crack ur software..
remember u must encrypt the data before store into register, else it was too easy to crack
please use ur own brain before give any criticism on other resource
alex jz share some with us we must say thank to him....
if got idea on the encrypt the u can jz maintion here rather then give criticism, get it....
or u can write a encrypt code to support the alex code....
P.S. remember use ur brain before give any criticism on other resource
I think i am right in saying that the savesettings command is a "cheap vb6" trick to enter registry data. It only saves the data in the HKEYLOCALMACHINE\SOFTWARE\Microsoft\DevStudio\6.0 section doesnt it?
I am not sure what would happen if the user doesnt have vb6 installed. Would it crash or fail to read/write the data, or would it create a section the relevant section keys for the user?
§¥Ñ©®ÕÑ¥ZË
This thread is for discussions of Create a "Trial" Period.