Access 2007-2016
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
 
Home   News   Tips   Glossary   Templates   Forums   Help   Logon   Order   Contact Us  
 
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
 
Accessindex
Excelindex
Wordindex
Windowsindex
PowerPointindex
Photoshopindex
Visual Basicindex
ASPindex
Seminars
More...
Customers
 
Account Login
Online Theater
Downloads
Lost Password
Free Upgrades
Insider Circle
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Articles
Search Our Site
Waiting List
Production Schedule
Collapse Menus
Help
 
Live Chat
Customer Support
WalkThru Tutorials
Troubleshooting
FAQs
TechHelp
Consulting Services
About Us
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Order
 
Video Tutorials
Handbooks
MYOLP Memberships
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Gift CDs
Contact
 
Live Chat
General Info
Support Policy
Contact Form
Email Us
Mailing Address
Phone Number
Fax Number
Course Survey
Facebook    Twitter

Google Plus    LinkedIn

Blog RSS Feed    YouTube Channel
Richard Rost Microsoft MVP