Boolean Registry Check

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

Is there a Registry Function out there that will simply check to see if
a Key exists and return Yes/No only? The Registry functions that I use
in my Access app check and If Not Exist Creates the key you are
searching for.

Thanks in Advance,

Randy
 
Randy said:
Is there a Registry Function out there that will simply check to see
if a Key exists and return Yes/No only? The Registry functions that
I use in my Access app check and If Not Exist Creates the key you are
searching for.

What functions are you using? CreateKey opens an existing key or creates a
new one, OpenKey just opens an existing key and errors if not found.
 
Create a function which tries to open the key, and has an error handler,
which if invoked, sets the return value of the function to false.
 
I am using both of them. Openkey returns nasty errors to the user, and
I want it to be transparent. Know of a way that I can use OpenKey and
tell the user that the Key isn't valid?
 
On Error Resume Next
.. OpenKey ...
If Err.Number <> 0 Then MsgBox "Reg Key does not exist"
Err.Clear
On Error Goto <Normal Error Handler> (or On Error Goto 0)

HTH

Pieter
 
Randy said:
I am using both of them. Openkey returns nasty errors to the user,
and I want it to be transparent. Know of a way that I can use
OpenKey and tell the user that the Key isn't valid?

The RegOpenKey API call doesn't raise any errors; it returns an error code
to the calling application. What you do with it at that point is up to you.
It sounds to me like maybe you are not checking the return value and just
assuming it worked and that's causing code further along to fail with errors
that you are not trapping.

Post the section of code involved (and your API declarations for the call
and any constants it uses)
 
Back
Top