对于从Registry获取Installed Application列表感到困惑

时间:2015-03-17 11:28:31

标签: c# winforms

我需要从注册表中安装程序列表并在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);
        }

     }

输出应该看起来像左边的第一张图片。但它不是 enter image description here

0 个答案:

没有答案