如何从注册表中获取安装的软件路径?

我需要替换安装在任何驱动器中的文件,如C,D,E …我想从注册表中找到已安装的文件路径,并将此文件替换为其他文件。 软件将安装在任何驱动器中。 我想替换文件。

我正在使用此代码。

如何找到已安装的文件路径并使用注册表替换为C#中的其他文件。

string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key)) { foreach (string subkey_name in key.GetSubKeyNames()) { using (RegistryKey subkey = key.OpenSubKey(subkey_name)) { // Console.WriteLine(subkey.GetValue("DisplayName")); if (subkey.GetValue("DisplayName") == "ActiveTeach Images Book 3") { } } } } 

您可以尝试以下代码获取App的“安装位置”吗?

 string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key)) { foreach (string subkey_name in key.GetSubKeyNames()) { using (RegistryKey subkey = key.OpenSubKey(subkey_name)) { // Console.WriteLine(subkey.GetValue("DisplayName")); if (subkey.GetValue("DisplayName").Equals("ActiveTeach Images Book 3")) { return subkey.GetValue("InstallLocation"); } } } }