I am working for application register form and I would like to know when the user opens the register form I need to check if the current date is true or not and when the user tries to change the system date he should pop up message.So I would like to refresh the form for every second and find whether he has changed the date or not.
How do I do that?
Here is my code:
btnRegister.Enabled = False
Dim oReg As Microsoft.Win32.RegistryKey
oReg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software", True)
oReg = oReg.CreateSubKey(kstrRegSubKeyName)
oReg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\" & kstrRegSubKeyName)
Dim strOldDay As String = oReg.GetValue("UserSettings", "").ToString
Dim strOldMonth As String = oReg.GetValue("operatingsystem", "").ToString
Dim strOldYear As String = oReg.GetValue("GUID", "").ToString
Dim strRegName As String = oReg.GetValue("USERID", "").ToString
Dim strRegCode As String = oReg.GetValue("LOCALPATH", "").ToString
Dim strCompID As String = oReg.GetValue("CompID", "").ToString
Dim strTrialDone As String = oReg.GetValue("Enable", "").ToString
oReg.Close()
'If the keys should automatically be created, then create them.
If strOldDay = "" Then
CreateRegKeys(txtPassPhrase.Text)
End If
'If the keys are encrypted, decrypt them.
'If EncryptKeys = True Then
strOldDay = Decrypt(txtPassPhrase.Text, strOldDay)
strOldMonth = Decrypt(txtPassPhrase.Text, strOldMonth)
strOldYear = Decrypt(txtPassPhrase.Text, strOldYear)
'End If
'Define global variables.
mintUsedTrialDays = DiffDate(strOldDay, strOldMonth, strOldYear)
'Fill the progress bar
lblApplicationStatus.Text = DisplayApplicationStatus(DiffDate(strOldDay, strOldMonth, strOldYear), mintTrialPeriod)
'Disable the continue button if the trial is over
If DiffDate(strOldDay, strOldMonth, strOldYear) > mintTrialPeriod Then
'unregbutton.Enabled = False
mblnInTrial = False
btnRemind.Enabled = False
oReg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software", True)
oReg = oReg.CreateSubKey(kstrRegSubKeyName)
oReg.SetValue("Enable", "1")
oReg.Close()
End If
If strOldMonth = "" Then
Else
Dim dtmOldDate As Date = New Date(Convert.ToInt32(strOldYear), Convert.ToInt32(strOldMonth), Convert.ToInt32(strOldDay))
If Date.Compare(DateTime.Now, dtmOldDate) < 0 Then
'lblApplicationStatus.Text = DisplayApplicationStatus(mintTrialPeriod, mintTrialPeriod)
lblApplicationStatus.Text = "The system clock has been manually changed, and the application has been locked out to prevent unauthorized access!"
End If
End If
'If the trial is done then disable the button
If strTrialDone = "1" Then
mblnInTrial = False
btnRemind.Enabled = False
lblApplicationStatus.Text = "The system clock has been manually changed, and the application has been locked out to prevent unauthorized access!"
End If
'See if the user is already registered, if so re-process the info and check if the computer is all okay.,
If strRegName = "" Then
Else
Dim strRN As String = Decrypt(txtPassPhrase.Text, strRegName)
Dim strRC As String = Decrypt(txtPassPhrase.Text, strRegCode)
Dim UserName As String = strRegName
UserName = UserName.Remove(16, (UserName.Length - 16))
If UserName = Decrypt(txtPassPhrase.Text, strRegCode) Then
If Encrypt(txtPassPhrase.Text, cHardware.GetMotherBoardID.Trim.ToString) = strCompID Then
mblnInTrial = False
mblnFullVersion = True
strRC = strRC.Insert(4, "-")
strRC = strRC.Insert(8, "-")
strRC = strRC.Insert(12, "-") 'Add dashes to make it look cool
lblApplicationStatus.Text = "Licensed version to " + strRN + " with the key " + strRC
txtVKClientName.Enabled = False
txtKeyToValidate.Enabled = False
txtVKClientName.Text = strRN
txtKeyToValidate.Text = strRC
btnRemind.Text = "Registered"
frmMain.Text = "Aquamark v1.2(Registered)"
btnRegister.Hide()
Me.Close()
frmMain.Show()
oReg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software", True)
oReg = oReg.CreateSubKey(kstrRegSubKeyName)
oReg.SetValue("Enable", "")
oReg.Close()
End If
End If
End If
NO, you don’t have to “
refresh the form for every second and find whether he has changed the date or not. How do I do that“, the solution is a lot easierThe windows will send a message to all applications when the data is changed. Listen to that message instead and whenever the data changed do what you want to do so:
//C# sorry I don’t know VB but the code is simple and you should convert it without any problem