Hi guys, need help here. I would like to check the registry key is exist for this code:

Sub main()
        Dim regKey As Object = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{D75F38ED-E49A-48F3-9B72-D4BC5FE73B44}", True)

        ' Check if it exists
        If regKey Is Nothing Then
            MsgBox("Registry key does not exist!")
        Else

            MsgBox("Registry key is exists.")

        End If
    End Sub

It telling registry key does not exist, but when i remove "{D75F38ED-E49A-48F3-9B72-D4BC5FE73B44}", it managed to find the registry key. So Im suspecting it couldn't detect special symbol like parentheses "{" & "}" ?

Anyone could help me to figure out?

I did this

Dim key As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{002568CE-7595-46A3-A1C1-53F41A4ADC34}"
Dim regKey As RegistryKey = Registry.LocalMachine.OpenSubKey(key, False)

If regKey Is Nothing Then
    MsgBox("Registry key does not exist!")
Else
    MsgBox("Registry key exists.")
End If

on my system (Windows 7 Pro) and it worked just fine. Note that I used False as the second parameter to avoid a System Security Exception.

Hi Jim, thanks for your reply.. but it still not work for me.. It only work when I replace the "{002568CE-7595-46A3-A1C1-53F41A4ADC34}" to "AddressBook", somewhat a proper english.. :(

I don't have that particular key so I can't run the same test, however, my example does show that the brace brackets are not the cause of the problem.

Hi Jim, I don't know what happened, but it just worked now. haha. Thanks a lot, man.

This question has already been answered. Start a new discussion instead.