因此,我找到了從這裏獲取已安裝程序列表的解決方案。 Get installed applications in a systemC#在windows上,如何獲得已安裝程序的目錄列表
但我想知道我是否可以得到他們每個人的安裝目錄?我需要它,因爲我需要找到該程序的所有可執行文件。
任何建議,將不勝感激。
因此,我找到了從這裏獲取已安裝程序列表的解決方案。 Get installed applications in a systemC#在windows上,如何獲得已安裝程序的目錄列表
但我想知道我是否可以得到他們每個人的安裝目錄?我需要它,因爲我需要找到該程序的所有可執行文件。
任何建議,將不勝感激。
你需要找到「HKLM \軟件\微軟\的Windows \ CurrentVersion \卸載」 所有已安裝的應用程序下面的示例代碼
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);
這個例子將顯示名稱鍵值比較,以你輸入的名字,如果它找到該值,則返回InstallLocation鍵值。
真誠,
Thiyagu拉金德倫
**請註明答覆作爲答案,如果他們幫助和取消標記,如果他們不。
TLDR:解決方案是使用Key:InstallLocation代替Key:DisplayName – libra
您是否嘗試檢查子鍵的InstallLocation值 - 它應該至少在非驅動程序/打印機/等等中存在。東東。 – Filburt