C#读取注册表,获取本机安装的软件清单

private void button1_Click(object sender, EventArgs e) { dataGridView1.Columns.Clear(); dataGridView1.Columns.Add("Name", "软件名"); dataGridView1.Columns.Add("Path", "地址"); using (RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"Software/Microsoft/Windows/CurrentVersion/Uninstall", false)) { if (key != null) { int index = 0; foreach (string keyName in key.GetSubKeyNames()) { using (RegistryKey key2 = key.OpenSubKey(keyName, false)) { if (key2 != null) { string softwareName = key2.GetValue("DisplayName", "").ToString(); string installLocation = key2.GetValue("InstallLocation", "").ToString(); if (!string.IsNullOrEmpty(installLocation)) { index = dataGridView1.Rows.Add(); dataGridView1["Name", index].Value = softwareName; dataGridView1["Path", index].Value = installLocation; } } } } } } }

C#读取注册表,获取本机安装的软件清单_第1张图片

你可能感兴趣的:(String,object,C#,null,Path,button)