Zdravím, rád bych dal uživatelům možnost vyzkoušet si program. Nejradši bych vytvořil trial verzi např. na 30 dnů, protože kdybych udělal demo, který ořežu, tak skoro nic nezbyde. Otázka je, jak toho nejlépe docílit. Napadlo mně použít tento kód, ale není moc bezpečný. Proto kdyby se hodnota zašifrovala a uložila jednak do registru, a jednak do ini, bylo by to relativně nenabouratelné řešení?
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
|