'Registry.GetValue goes to another path (C#) [duplicate]

i have the next problem. When i execute a registry.getvalue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server","InstalledInstances",null);

it returns me the default value (null), when i search subkey's with Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server").GetValueNames() returns me "IsListenerActive" and search in regedit this name value and it is in the next path HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SQL Server.

first, why does this happend? second, how can i fix it?

context: i try to find the sql server's instance name with code.

thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source