Help on trial version

daveofgv

Well-known member
Joined
Sep 17, 2008
Messages
218
Location
Dallas, TX
Programming Experience
1-3
I have a set of code in a program that allows the user to access my program for only 15 days. If the user sets his/her date to a different date then the code is suppose to see it and send a message that the software has seen the date change. On the second time the user changes that date my program is suppose to end. However, for some reason, it is not seeing the date change when I manually change my date on my computer.

Here is the code....... Can anyone see why it will not see the date change? I am using visual studio 2008 pro.....


VB.NET:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        End
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim intTime As Integer = 1
        Dim dteLastStart, dteStartDate As Date
        Dim blnFirstTime, blnEnabled As Boolean
        Dim lngTimeLeft As Long

        blnEnabled = True
        If dteStartDate = Nothing Then
            dteStartDate = Now
        End If

        My.Application.SaveMySettingsOnExit = True

        If DateDiff(DateInterval.Day, dteLastStart, Now) < 0 Then
            'First clock change
            If intTime = 1 Then
                MsgBox("This software has detected that you have changed your system date to an earlier date" & vbCrLf _
                & "As this softwaer has built-in security," & vbCrLf _
                & "this software will only run until the next intTime you change your system date", _
                MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation, "System Date Changed")
                intTime = 2
            ElseIf intTime = 2 Then
                'Second clock change
                blnEnabled = False
                MsgBox("This software has detected that you have changed your system date to an earlier date" & vbCrLf _
                & "As this is the second warning, this software will now be disabled", _
                MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation, "System Date Changed")
            End If
            'disables app
            If blnEnabled = False Then
                If MsgBox("Software is disabled", MsgBoxStyle.OkOnly Or MsgBoxStyle.Information, "Disabled") = MsgBoxResult.Ok Then
                    For Each form As Form In My.Application.OpenForms
                        form.Close()
                    Next
                End If
            End If
        End If
        If DateDiff(DateInterval.Day, dteStartDate, Now) > 15 Then
            blnEnabled = False
            If blnEnabled = False Then
                If MsgBox("This software has reached the end of it's trial.", MsgBoxStyle.OkOnly Or MsgBoxStyle.Information, "Trial Ended") = MsgBoxResult.Ok Then
                    'Close all open forms
                    For Each form As Form In My.Application.OpenForms
                        form.Close()
                    Next
                End If
            End If
        End If
        dteLastStart = Now
        If blnFirstTime = True Then
            blnFirstTime = False
        End If
        'Saves variable settings
        My.Settings.Save()

        lngTimeLeft = 15 - (DateDiff(DateInterval.Day, dteStartDate, Now))

        MsgBox("This software is a trial version and can only be used for 15 days." _
        & "If you would like to purchase this software please contact DMB Software for the full version" & vbCrLf _
        & "You have " & CStr(lngTimeLeft) & " days left.", _
        MsgBoxStyle.OkOnly, "Software Trial")

    End Sub
End Class



Thank you in advanced for your help

daveofgv
 
Last edited by a moderator:
Back
Top