我尝试获取已安装的应用程序密钥列表:
RegistryKey RegKeyUninstallList = Registry.LocalMachine;
string strUninstallList = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
string[] test = RegKeyUninstallList.OpenSubKey(strUninstallList).GetSubKeyNames();
我只得到钥匙:
HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ Microsoft \ Windows \ CurrentVersion \ Uninstall
但我还需要来自以下的钥匙:
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Uninstall
我的程序应该能够在 64Bit
和 32Bit
机器上运行 .
编辑:好的我已经尝试了Check if application is installed in registry和来自tHiNk_OuT_oF_bOx的解决方案 .
但没有解决问题!
问题是我得到完全相同的test和test2列表:
RegistryKey RegKeyUninstallList = Registry.LocalMachine;
string strUninstallList = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
string strUninstallList2 = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
string[] test = RegKeyUninstallList.OpenSubKey(strUninstallList).GetSubKeyNames();
string[] test2 = RegKeyUninstallList.OpenSubKey(strUninstallList2).GetSubKeyNames();
4 回答
来自:http://social.msdn.microsoft.com/Forums/en-US/94c2f14d-c45e-4b55-9ba0-eb091bac1035/c-get-installed-programs
解决方案是在注册表中搜索3个位置:
在CurrentUser中
在LocalMachine中
在LocalMachine中
以下代码适合您的需要 .
您是否可以尝试在项目中添加引用“System.Management”并在使用此代码后:
我觉得更容易
看来你现在必须使用OpenBaseKey,有代码即时使用: