How do I check if a registry entry exists in the windows registry.
-
:confused:I just started learning the vb.net and I would like to know how can I check if a subkey exists in the registry and use a code to create the subkey it if does not exist in the registry. All help will be welcome. Thank you, Simon:confused:
-
:confused:I just started learning the vb.net and I would like to know how can I check if a subkey exists in the registry and use a code to create the subkey it if does not exist in the registry. All help will be welcome. Thank you, Simon:confused:
There is an example of this very topic on the samples for VB.NET:
Private Sub DoesKeyExist
Dim regVersion As Microsoft.Win32.RegistryKey
regVersion = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\TestApp\\1.0", True)
If regVersion Is Nothing Then
regVersion = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("SOFTWARE\\Microsoft\\TestApp\\1.0")
End If
End SubThis will check to see if a key exists, then if not, creates it. Oh yeah! It also needs a reference to the Win32 namespace. RageInTheMachine9532