Using the Registry. How to know if Key exists?

Rick Stanich

King and Supreme Ruler
Local time
Today, 12:41
Joined
May 13, 2009
Messages
93
(Solved) Using the Registry. How to know if Key exists?

This is a sample structure.
HKEY_CURRENT_USER\Software\VB and VBA Program Settings\GeoMeasure\CMM Data\
The text in orange is the AppName, the text in violet is the Key.
Writing to and reading from the registry is easy to do, determining if a "AppName" or "Key" exists is not so easy.
In this case the string "HKEY_CURRENT_USER\Software\VB and VBA Program Settings" will always be the same, its the standard naming thru VBA.

How can I find out if a specific Key exists in "HKEY_CURRENT_USER\Software\VB and VBA Program Settings"?

FYI
There is an example for "IsBroken" but it appears to be for file association only.
 
Last edited:
Here is a mod I use that has several functions that will help you. Obviously they are for an application I already have so you need to change the reg keys accordingly.

Save this file a standard module in your front end.

David
 

Attachments

Impressive, I will have to study that one. ;)

I found a method that works on Excelforum.com (c/o romperstomper)
http://www.excelforum.com/excel-programming/705956-using-the-registry-how-to-know-if-key-exists.html
(cross post)
Not quite as impressive, but it does what I need.
Code:
Sub testreg()
    Dim varSettings
    varSettings = GetSetting("GeoMeasure", "CMM Data", "sJobNo")
    If varSettings = "" Then
    MsgBox "no such Application/key combination"
    Else
    MsgBox "Ok"
    End If
End Sub
 
GetSetting is ok but you have limitations and is not as flexible.

David
 

Users who are viewing this thread

Back
Top Bottom