c#怎么读取注册表某目录下所有的字符串值名称并显示到dataGridView1上

如题所述

        private void button1_Click(object sender, EventArgs e)
        {
            RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\MICROSOFT\\INTERNET EXPLORER\\MAIN");
            if(rk != null)
            {
                foreach (string name in rk.GetValueNames())
                {
                    if (rk.GetValueKind(name) == RegistryValueKind.String)
                    {
                        int rowIndex = dataGridView1.Rows.Add();
                        dataGridView1.Rows[rowIndex].Cells[0].Value = name;
                    }
                }
                rk.Close();
            }
        }

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答