1. How to make my application to work only for 30 days i.e., as an demo application
2. How to make my application to run only one instance?
S.Desikan
Printable View
1. How to make my application to work only for 30 days i.e., as an demo application
2. How to make my application to run only one instance?
S.Desikan
good morning desi_in :)
Quote:
2. How to make my application to run only one instance?
VB Code:
Private Sub Form_Load() If App.PrevInstance = True Then AppActivate "AppName" Unload Me End If End Sub
here is a sample on how to protect your app. Its not the best protection, but it should get you started :)
VB Code:
Option Explicit Public Function DateGood(NumDays As Integer) As Boolean 'The purpose of this module is to allow you to place a time 'limit on the unregistered use of your shareware application. 'This module can not be defeated by rolling back the system clock. 'Simply call the DateGood function when your application is first 'loading, passing it the number of days it can be used without 'registering. ' 'Ex: If DateGood(30)=False Then ' CrippleApplication ' End if 'Register Parameters: ' CRD: Current Run Date ' LRD: Last Run Date ' FRD: First Run Date Dim TmpCRD As Date Dim TmpLRD As Date Dim TmpFRD As Date TmpCRD = Format(Now, "m/d/yy") TmpLRD = GetSetting(App.EXEName, "Param", "LRD", "1/1/2000") TmpFRD = GetSetting(App.EXEName, "Param", "FRD", "1/1/2000") DateGood = False 'If this is the applications first load, write initial settings 'to the register If TmpLRD = "1/1/2000" Then SaveSetting App.EXEName, "Param", "LRD", TmpCRD SaveSetting App.EXEName, "Param", "FRD", TmpCRD End If 'Read LRD and FRD from register TmpLRD = GetSetting(App.EXEName, "Param", "LRD", "1/1/2000") TmpFRD = GetSetting(App.EXEName, "Param", "FRD", "1/1/2000") If TmpFRD > TmpCRD Then 'System clock rolled back DateGood = False ElseIf Now > DateAdd("d", NumDays, TmpFRD) Then 'Expiration expired DateGood = False ElseIf TmpCRD > TmpLRD Then 'Everything OK write New LRD date SaveSetting App.EXEName, "Param", "LRD", TmpCRD DateGood = True ElseIf TmpCRD = Format(TmpLRD, "m/d/yy") Then DateGood = True Else DateGood = False End If End Function 'Usage Private Sub Form_Activate() If Not DateGood(30) Then MsgBox "Trial Period Expired!", vbExclamation, "Unregistered application" Unload Me End If End Sub
Ok.. correct me if I wrong. But, I tried this code.. and then went into my registry... HKEY_CURRENT_USER\Software\VB and VBA Program Settings, and I find the program name with FRD and LRD (First Run Date, Last Run Date) sitting right there.. with the actual dates in them. So.. using this method, wouldn't one just have to change the date to beat this code? I've never done any registry work.. so I'm just trying to understand it.
Thx all!
I would encrypt the dates, and make the reg keys names a bit more obscure. You could also use the registry APIs to store the info in different place in the registry.
Tg
No doubt. As peet mentioned its a demo and not the best protection. However, I'tQuote:
Originally Posted by jolene_keagy
may give you a place to start. What you can now do is use some 'encryption' alorithim
to save out the date and decoded when read back in for validation.
Bruce.
thx all! :wave:
Jolene