[英]C# On windows, how to get a list of installed programs' directories
因此,我找到了从此处获取已安装程序列表的解决方案。 在系统中获取已安装的应用程序
但是我想知道是否可以获取每个目录的安装目录吗? 我需要它,因为我需要找到该程序的所有可执行文件。
任何建议,将不胜感激。
您需要从“ HKLM \\ Software \\ Microsoft \\ Windows \\ CurrentVersion \\ Uninstall”中找到所有已安装的应用程序,这是示例代码
private string FindByDisplayName(RegistryKey parentKey, string name)
{
string[] nameList = parentKey.GetSubKeyNames();
for (int i = 0; i < nameList.Length; i++)
{
RegistryKey regKey = parentKey.OpenSubKey(nameList[i]);
try
{
if (regKey.GetValue("DisplayName").ToString() == name)
{
return regKey.GetValue("InstallLocation").ToString();
}
}
catch { }
}
return "";
}
RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
string location = FindByDisplayName(regKey, "MSN");
MessageBox.Show(location);
本示例将DisplayName键值与您的输入名称进行比较,如果找到该值,则返回InstallLocation键值。
此致
蒂亚古·拉詹德兰(Thiyagu Rajendran)
**如果有帮助,请标记为答复,否则为不标记。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.