如何从注册表中安装的软件路径? [英] How to get installed software path from registry?
本文介绍了如何从注册表中安装的软件路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要更换它安装在像C,D,E的任何驱动器的文件......我想找到注册表中的安装文件路径和替换此文件为其他文件。软件将被安装在任何驱动器。我要替换文件。
我使用这个代码。
如何找到安装文件路径和使用注册表替换为其他文件在C#。
字符串registry_key = @SOFTWARE\Microsoft\Windows\CurrentVersion\卸载;使用
(Microsoft.Win32.RegistryKey键= Registry.LocalMachine.OpenSubKey(registry_key))
{
的foreach(字符串key.GetSubKeyNames subkey_name())
{
按(子项的RegistryKey = key.OpenSubKey(subkey_name))
{
// Console.WriteLine(subkey.GetValue(显示名称));
如果(subkey.GetValue(显示名称)==ActiveTeach影像书3)
{
}
}
}
}
解决方案
您可以试试下面的代码应用程序中获得安装位置?
字符串registry_key = @SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall 使用
(Microsoft.Win32.RegistryKey键= Registry.LocalMachine.OpenSubKey(registry_key))
{
的foreach(字符串key.GetSubKeyNames subkey_name())
{
按(子项的RegistryKey = key.OpenSubKey(subkey_name))
{
// Console.WriteLine(subkey.GetValue(显示名称));
如果(subkey.GetValue(显示名称)等于(ActiveTeach影像书3)。)
{
返回subkey.GetValue(INSTALLLOCATION);
}
}
}
}
I need to replace the file which is installed in any drive like C,D,E... I want to find the installed file path from registry and replace this file to other file. software will be installed in any drive. I want to replace file.
I am using this code.
how to find the installed file path and replace to other file in C# using registry.
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")
{
}
}
}
}
解决方案
Could you try below code get "Install Location" of 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");
}
}
}
}
这篇关于如何从注册表中安装的软件路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文