Hi all,
I am trying to figure out how to check if a registry key exists. If it does, do nothing, if it doesn't, recreate it.
I've found numerous resources on the subject, and have made progress, but one little thing is stoping me.
Here is my code that I have so far:
The problem is that this reports "Not Found", even though the key 'regkey' exists in the registry. Also, if I remove 'regkey' from the code, it reports "Found". So it does find the subdirectory in the registry.
My question is, how do I check to see if the 'regkey' exists?
I'm running Windows XP Pro SP2. Thanks.
I am trying to figure out how to check if a registry key exists. If it does, do nothing, if it doesn't, recreate it.
I've found numerous resources on the subject, and have made progress, but one little thing is stoping me.
Here is my code that I have so far:
VB.NET:
Dim regKey As Microsoft.Win32.RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\application\regkey", True)
If regKey Is Nothing Then
MsgBox("Not Found")
Else
MsgBox("Found")
End If
My question is, how do I check to see if the 'regkey' exists?
I'm running Windows XP Pro SP2. Thanks.
Last edited: