So I found the solution of getting a list of installed programs from here. Get installed applications in a system
But I wonder if I can get the installed directory of each of them? I need it because i would need to find all the executable files for that program.
Any suggestions would be appreciated.
You need to find all installed app from "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall" Here is the sample code
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);
This example will compare the DisplayName keyvalue to your input name, if it find the value, then return the InstallLocation key value.
Sincerely,
Thiyagu Rajendran
**Please mark the replies as answers if they help and unmark if they don't.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.