VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



To Store and Retrive Values to Registry

by Raghuraja.C (12 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 6th February 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

To Store and Retrive Values to Registry

API Declarations


Dim datInActiveDate As Date
Dim datNotValid As Date
Dim datStarted As Date
Dim datFinished As Date

Rate To Store and Retrive Values to Registry




  'First Get the Value from the Registry
  strStoredFromRegistry = GetSetting("Win32rgc", "WhenGoingToInActive", "WhichDateStarted")

  'If the Registry Value is not set then Set he Value
  If Len(Trim(strStoredFromRegistry)) < 1 Then
     SaveSetting "Win32rgc", "WhenGoingToInActive", "WhichDateStarted", Date
     'Add 50 days to the Current Date
     datInActiveDate = DateAdd("d", 50, Date)
     'Here I have Given 15 days for expiration of the Software You can Give 'n' no of days as you like
     SaveSetting "Win32rgc", "WhenGoingToInActive", "WhichDateStarted", datInActiveDate
  Else
     'If this Registry Value is not Set then
     datNotValid = GetSetting("Win32rgc", "WhenGoingToInActive", "WhichDateStarted")
     If Len(Trim(datNotValid)) < 1 Then
         'Get the Previously set Initial Value from the Registry
         strStoredFromRegistry = GetSetting("Win32rgc", "WhenGoingToInActive", "WhichDateStarted")
         datStarted = CDate(strStoredFromRegistry)
         'Get the Expiry Value from the Registry
         datFinished = GetSetting("Win32rgc", "WhenGoingToInActive", "WhichDateStarted")
         datInActiveDate = CDate(datInActiveDate)
         'Compare Registry Values with the Date, if they are bound with in the Initial Value of the Software and Expiry Value of the SOftware then only the Program will run
         If Date > datInActiveDate Or Date < datStarted Then
            'Now set the Used Date value to True
            SaveSetting "Win32rgc", "Expiry", "Used Date", "True"
            MsgBox "Your Application has Expired; You cannot run this Application.", vbExclamation, "Application Expired"
            End
         Else
            MsgBox " " & datFinished - Date & " days of evaluation period is remaining", vbExclamation, "Application Expired"
         End If
      Else
         MsgBox "Application has Expired; You cannot run this Application.", vbExclamation, "Application Expired"
         End
      End If
  End If


Download this snippet    Add to My Saved Code

To Store and Retrive Values to Registry Comments

No comments have been posted about To Store and Retrive Values to Registry. Why not be the first to post a comment about To Store and Retrive Values to Registry.

Post your comment

Subject:
Message:
0/1000 characters