I cant get the following code to check if my regestrykey exists can some one help. the idea is to check if it exists if so do nothing if not create it, along with its value…
the full key is HKEY_LOCAL_MACHINE\SOFTWARE\VTS\Advanced Offset 2\Admin\Access
> If Dir$("HKEY_LOCAL_MACHINE\SOFTWARE\VTS\Advanced Offset 2\Admin", vbDirectory) <> "" Then Else MsgBox(".NET Framework 2.0") End If
UPDATED CODE:
Dim l_subKeyPath As String = "SOFTWARE\VTS\Advanced Offset 2\Admin\Access" Dim l_regKey As RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey(l_subKeyPath, False) If (l_regKey Is Nothing) Then 'if nothing then key doesn't exists 'Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\VTS\Advanced Offset 2\Admin", "ACCESS", "PASSWbORD") MsgBox("yess") Else 'key exists MsgBox("no") End If
Try this:
Quoting MSDN:
RegistryKey.OpenSubKey Method