registry key exists

Talk2Tom11

Well-known member
Joined
Feb 22, 2004
Messages
144
Location
Westchester, NY
I want to write and if statment for if a key in the registry exists.

the key is under HKEY_CURRENT_USER\TEST123\TEST

the key name is Hello, with the value, 1234

and I just want to make an if statement that checks if it exists, if it does, have a msgbox that says, yes and if not then one that says no.
 
Well...

Code:
Imports Microsoft.Win32
Dim regKey As RegistryKey
Dim keyValue As String
keyValue = "TEST123\TEST"
regKey= Registry.CurrentUser.OpenSubKey(keyValue, False)

If (regKey Is Nothing) Then
    Messagbox.show("Registry Value exists")
ELSE
   Messagebox.show("Registry Value does not exist")
End If
regKey.Close()
 
Back
Top