[RESOLVED] Registry Key Exists
I'm having a hard time determining if a registry exists or not. This is what I'm trying:
VB.NET Code:
Dim r4 As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full")
If Not r4 Is Nothing Then
If Not r4.GetValue("Version") Is Nothing Then
Return CStr(r4.GetValue("Version"))
Else
Return "4"
End If
End If
The registry key exists on my PC, so I'm having a hard time debugging it on another PC. When it threw the error, I commented out the last block of code to see if I was checking the key wrong or if it would throw the error just on the variable declaration.
Which is did. I get why it did. You can't .Open a key that doesn't exist. However, I looked it up and everyone is recommending that we do it this way. But this way doesn't exist.
Anyone have any ideas?