0

I am using GetSubKeysNames function to get subkey from {HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall}. But it returns diffrent subkeys count. In C# returns 371 subkeys, in visual basic returns 61 subkeys. Where am i wrong?

Here is some code and pic.

C#

string[] deneme = unistallKey.GetSubKeyNames();

enter image description here

VB

Dim deneme() As String = UninstallKey.GetSubKeyNames

enter image description here

mburakerbay
  • 63
  • 11
  • Take a look at this: http://stackoverflow.com/questions/3112181/registry-getsubkeynames-lists-different-keys-than-regedit – Carlos Landeras Nov 14 '12 at 07:55
  • What is `UninstallKey`? you should post the code where you obtain the sub key's not where you'r using them. – DjSol Nov 14 '12 at 07:57
  • Unistallkey is HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall and i want to get HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall's subkeys. I am not using, i am trying to obtain them here. – mburakerbay Nov 14 '12 at 09:08

2 Answers2

1

I have the same problem, and using the code below, the problem was solved.

 Dim rk1 As RegistryKey = Microsoft.Win32.RegistryKey.OpenBaseKey _
                                    (Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64)
        Dim rk2 As RegistryKey = Microsoft.Win32.RegistryKey.OpenBaseKey _
                                    (Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64)
        Dim rk3 As RegistryKey = Microsoft.Win32.RegistryKey.OpenBaseKey _
                                    (Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64)

    rk1 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)

    regpath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

    rk2 = rk1.OpenSubKey(regpath)

    For Each subk As String In rk2.GetSubKeyNames

        rk3 = rk2.OpenSubKey(subk, False)

        value = rk3.GetValue("DisplayName", "")

        If value <> "" Then
            includes = True
            If value.IndexOf("Hotfix") <> -1 Then includes = False
            If value.IndexOf("Security Update") <> -1 Then includes = False
            If value.IndexOf("Update for") <> -1 Then includes = False
            If value.IndexOf("Service Pack") <> -1 Then includes = False

            For vAtual = 0 To UBound(Softwares)
                If value = Softwares(vAtual) Then
                    includes = False
                End If
            Next

            If includes = True Then
                gridSoft.Rows.Add(value, rk3.GetValue("InstallDate", ""), rk3.GetValue("UninstallString", ""), rk3.GetValue("EstimatedSize", ""), rk3.GetValue("InstallLocation", ""), rk3.GetValue("Publisher", ""))
                Softwares(vCont) = value
                vCont = vCont + 1
            End If

        End If
    Next
Thomas G
  • 9,886
  • 7
  • 28
  • 41
0

May be some of your programs are installed under 32 bit and some are under 64 bit. Enumerate through the following key:

HKEY_LOCAL_MACHINE\Software\WOW6432node\

Shivam Gupta
  • 429
  • 4
  • 16
  • i am checking both of them but the issue is in under HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall – mburakerbay Nov 23 '12 at 09:25