-1

Ok, so i have some code that will go through the registry and add the software installed to listbox1. The issue i'm having, is that the results are not fully there. If a registry keys starts with {RandomNumber}, it does not show up in the listbox. It's there in the registry, but just not showing up in the listbox. Can someone please explain why or how to fix this? Listing my code below.

Dim appPATH As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
        Using rk As RegistryKey = Registry.LocalMachine.OpenSubKey(appPATH)
            For Each Name As String In rk.GetSubKeyNames()
                Using sk As RegistryKey = rk.OpenSubKey(Name)
                    Dim displayName = sk.GetValue("DisplayName")
                    Dim installDate = sk.GetValue("InstallDate")
                    Dim version = sk.GetValue("DisplayVersion")
                    Dim displayIcon = sk.GetValue("DisplayIcon")
                    If displayName = "" Then
                    Else
                        ListBox1.Items.Add(displayName + " " + version)
                    End If




                End Using

            Next
        End Using

Example of a Program (Duo) that is installed but not getting returned.

gunr2171
  • 16,104
  • 25
  • 61
  • 88
  • Does this answer your question? [OpenSubKey() returns null for a registry key that I can see in regedit.exe](https://stackoverflow.com/questions/13728491/opensubkey-returns-null-for-a-registry-key-that-i-can-see-in-regedit-exe) – Tu deschizi eu inchid Jan 26 '22 at 01:45

1 Answers1

0

For anyone that is curious....turns on that 64 bit computers are redirected by default. So when you go to build your program, choose 64bit CPU as the architecture. Then if you need to access 32 bit registry, use the following code example. The difference is the Wow6432Node key that you need to access.

Dim appPATH As String = "Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
        Using rk As RegistryKey = Registry.LocalMachine.OpenSubKey(appPATH)
            For Each Name As String In rk.GetSubKeyNames()
                Using sk As RegistryKey = rk.OpenSubKey(Name)
                    Dim displayName = sk.GetValue("DisplayName")
                    Dim installDate = sk.GetValue("InstallDate")
                    Dim version = sk.GetValue("DisplayVersion")
                    Dim displayIcon = sk.GetValue("DisplayIcon")
                    If displayName = "" Then
                    Else
                        ListBox1.Items.Add(displayName + " " + version)
                    End If
                End Using
            Next
        End Using