0

I am use method from this: Check if application is installed in registry to find "Sql Server 2019".

Problem is when i run program with active solution platforms: Any CPU.

string registryKey64 = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
string registryKey32 = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";

RegistryKey key64 = Registry.LocalMachine.OpenSubKey(registryKey64);
RegistryKey key32 = Registry.LocalMachine.OpenSubKey(registryKey32);

In then key64 == key32. Which causes it not to find a 64 bit sql server. Problem dont occurs in the opposite direction.

I dont want run program for platforms 64 bits. How can I get into the 64 bits registers?

Silny ToJa
  • 1,815
  • 1
  • 6
  • 20

1 Answers1

0

My solution:

string registryKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
RegistryKey key64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, 
RegistryView.Registry64);
RegistryKey key = key64.OpenSubKey(registryKey);
if (key != null)
{
    var list = key.GetSubKeyNames().Select(keyName => key.OpenSubKey(keyName).GetValue("DisplayName")).ToList();

    key.Close();
}
Silny ToJa
  • 1,815
  • 1
  • 6
  • 20