Access 2007-2019
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
 
Home   Courses   Seminars   Templates   Help   TechHelp   Forums   Contact   Join   Order   Logon  
 
Tips & Tricks

New Tips Added Weekly!
Click here to get on our Mailing List

   
 
MS Access

Reg Key Addendum

How to add a Reg Key



The Registration Seminar assumed the existance of "VB and VBA Program Settings" folder.

If this doesn't exist you can't use the built in VBA GetSetting and SaveSetting.

Instead we will need to use some Shell Scripting.

Create a Form with three textboxes

  • txtKey
  • txtValue
  • txtPath

frmKey    frmKey (2)

Then you can add the following Code which uses the below Functions.

	Private Sub cmdCreateKey_Click()
		RegKeySave txtPath & txtKey, txtValue
		MsgBox "Reg Key Added"
	End Sub
	

Check the Registry Key exists.

RegEdit

You can add necessary checks that the path is correct and the value is correct.

Code:

Read Key

	Function RegKeyRead(regKey As String) As String
		Dim ws As Object
		On Error Resume Next
		Set ws = CreateObject("WScript.Shell")
		RegKeyRead = ws.RegRead(regKey)
	End Function
	

MS Article

Save Key

	Sub RegKeySave(regKey As String, regValue As String, _
		Optional regType As String = "REG_SZ")
		Dim ws As Object
		Set ws = CreateObject("WScript.Shell")
		ws.RegWrite regKey, regValue, regType
	End Sub
	

MS Article

Registry Value Types
ValueType
REG_SZA string. If the type is not specified, this will be used as Default.
REG_DWORDA 32-bit number
REG_EXPAND_SZA string that contains unexpanded references to environment variables
REG_BINARYBinary data in any form. You really shouldn't touch such entries

MS Article

Delete Key

	Function RegKeyDelete(regKey As String) As Boolean
		Dim ws As Object
		On Error GoTo ErrorHandler
		Set ws = CreateObject("WScript.Shell")
		ws.RegDelete regKey
		RegKeyDelete = True
		Exit Function
		
	ErrorHandler:
		RegKeyDelete = False
	End Function
	

MS Article

Check Key Exists

	Function RegKeyExists(regKey As String) As Boolean
		Dim ws As Object
		On Error GoTo ErrorHandler
		Set ws = CreateObject("WScript.Shell")
		ws.RegRead regKey
		RegKeyExists = True
		Exit Function
		
	ErrorHandler:
		RegKeyExists = False
	End Function
	

Sample Files
Registration.accdb


I've create a small .NET app that uses the Formula from the Seminar to generate the Key needed to give to the customer.

Registration Generator

Let me know if you'd like this written up as a mini Article.

Sample Files
RegistrationKeyGenerator.zip


 

Alex Hedley (Avatar) By: Alex Hedley


Click here to sign up for more FREE tips

 

You may want to read these articles from the 599CD News:

 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Account Login
Online Theater
Downloads
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Blog RSS Feed    Twitter

YouTube Channel    LinkedIn