0

Using RegistryKey in C# I'm trying to find a specific software in:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

But even though I pass this path to SubKey, I get back this path instead:

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall

Code:

public void GetSubKeys(RegistryKey SubKey)
{
    List<string> viList = new List<string>();
    string[] val = SubKey.GetSubKeyNames();
    foreach (var VARIABLE in val)
    {
        RegistryKey SubKey1 = SubKey.OpenSubKey(SubKey + @"\" + VARIABLE);
        if (SubKey1.ToString().Contains("MySw"))
        {
            viList.Add(VARIABLE);
        }
     }
}

I know that because I'm searching for a specific SW which is not located in the WOW6432Node registry key, but in the other key, and there are various sw which are shown in the WOW6432Node key and not in the first key...

How come?

Any ideas?

Haroldo Gondim
  • 7,725
  • 9
  • 43
  • 62
roy.me
  • 421
  • 2
  • 7
  • 19
  • I'm guessing you're running the program compiled as `x86`, not `Any CPU`? – Joachim Isaksson Apr 14 '16 at 18:11
  • 3
    It's due to registry redirection for 32bit processes vs. 64bit in windows. You need to use the [OpenBaseKey](https://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.openbasekey(v=vs.110).aspx) method where you specify 32bit or 64bit "view" of the registry. [Here](http://stackoverflow.com/a/13232372/5095502) is a fairy comprehensive answer. If you search around there are [others](http://stackoverflow.com/a/15424697/5095502) too. – Quantic Apr 14 '16 at 18:15
  • Ok, Thank you very much. all your links helped a lot and solved my problem! – roy.me Apr 14 '16 at 19:43

0 Answers0