I'm trying to get the install path of a program from the registry using code that I will include in my project.
I pieced together some code to do the job but found it is looking in the wrong place.
The registry entry that I need to get is in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
I have manually checked this so I know it is there but I can't seem to get this code to work.
My problem is that even though the code is set to use "Software\Microsoft\Windows\CurrentVersion\Uninstall" it is looking in HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall
The test form only has one button called Button1 and one ListBox called ListBox1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim List As New List(Of String)
Dim Regkey, Subkey As Microsoft.Win32.RegistryKey
Dim ProgramName As String
Dim Regpath As String = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
Regkey = My.Computer.Registry.LocalMachine.OpenSubKey(Regpath)
Dim Subkeys() As String = Regkey.GetSubKeyNames
For Each subk As String In Subkeys
Subkey = Regkey.OpenSubKey(subk)
ProgramName = Subkey.GetValue("DisplayName", "").ToString
'If ProgramName <> "" Then
List.Add(Regkey.ToString & Chr(9) & subk & Chr(9) & ProgramName)
'End If
Next
List.Sort()
For i = 0 To List.Count - 1
ListBox1.Items.Add(List(i))
Next
End Sub
Any ideas why it seems to revert to "SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" instead of using "Software\Microsoft\Windows\CurrentVersion\Uninstall" and how to fix it?