我需要从注册表中安装程序列表并在ListView中显示它们。我正在使用此代码执行此操作
private void button1_Click(object sender, EventArgs e)
{
RegistryKey uninstallKey = Registry.LocalMachine.OpenSubKey(UninstallPath);
foreach (var subKey in uninstallKey.GetSubKeyNames())
{
using (RegistryKey key=uninstallKey.OpenSubKey(subKey,false))
{
ListViewItem lvItem =
new ListViewItem(key.GetValue("DisplayName") == null
? "********"
: key.GetValue("DisplayName").ToString());
listView1.Items.Add(lvItem);
}
}
输出应该看起来像左边的第一张图片。但它不是