licensing in vb.net
-
One option would be to store the date the application was installed/should expire in the registry either during installation or the first time the user runs the app. Then insert code to check that registry value. In Visual Studio 2005 you can do this check in the ApplicationEvents.vb MyApplication_Startup Event. Like this:
Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
'If the current date is greater than or equal to the Expiration date, then the program will not open.
If CInt(Now.Date.ToString("yyyyMMdd")) >= gblintExpireDate Then
MessageBox.Show(My.Application.Info.ProductName & " has expired.", My.Application.Info.ProductName)
e.Cancel = True
End If
End Sub(Of course the gblintExpireDate would have to be a value from the registry instead of a global constant like I use) Or for other versions of Visual Studio I suppose you can do this check in the OnLoad of the first form or in your main sub... Hope this helps.
-
You could (instead of licensing) write the date when the program was installed to a key in the registry, and if the program is started when more than 30 days have gone by, the program won't start. ---- Dim Sleepy as Boolean = True If Me.Sleepy = True Then Goto Sleep End If ----