Can't check for existence of Registry key. Help.

  • Thread starter Thread starter Mugsy_in_Houston
  • Start date Start date
M

Mugsy_in_Houston

Guest
I'm trying to check for the existence of a Registry key, but every online example I've tried doesn't work.

My code:

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Is Skype installed?
If My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Skype", "Name", Nothing) Is Nothing Then
MsgBox("Skype not installed.", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Skype not found")
End
End If
End Sub

.
The result is always "Nothing". I've verified the "Skype" Key exists at that location in my Registry, but still it returns whatever the third argument is set to. If I change "Nothing" to "Test", it returns "Test".

I've also tried searching for a fake key that does NOT exist (eg: "HKEY_CURRENT_USER\Software\Junk") but it made no difference. I've tried changing "Name" to something else but that too had no effect. I've tried checking for Registry string values I know exist, but the result is always "Nothing" (or whatever the third switch is set to.)

I don't know if it matters, but I'm using Win7 and just upgraded VS from 2017 to 2019, and when I launch my test app, I first get 6 "scripting" errors that have nothing to do with my code (I close the dialogs and the program still runs.) I'll worry about annoying VS2019 errors later.

How do I simply verify if a Key exists from VB? TIA

Continue reading...
 
Back
Top