码迷,mamicode.com
首页 > 其他好文 > 详细

读写注册表 registrykey 创建删除

时间:2016-05-08 23:49:57      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.listBox1.Items.Clear();
            RegistryKey abc = Registry.LocalMachine;
            RegistryKey sub = abc.OpenSubKey(@"software",true);
            RegistryKey test= sub.CreateSubKey("clp2016test");
            test.SetValue("testapp","dasfdf");
            foreach (string str in sub.GetSubKeyNames())
            {
                listBox1.Items.Add("子项名 :" + str);
                RegistryKey subname = sub.OpenSubKey(str);
                foreach (string sSubname in subname.GetValueNames())
                {
                    listBox1.Items.Add(sSubname+" 值: "+subname.GetValue(sSubname));
                }
            }

           


        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.listBox1.Items.Clear();
            RegistryKey abc = Registry.LocalMachine;
            RegistryKey sub = abc.OpenSubKey(@"software", true);// 权限
            sub.DeleteSubKeyTree("clp2016test"); //删除
            foreach (string str in sub.GetSubKeyNames())
            {
                listBox1.Items.Add("子项名 :" + str);
                RegistryKey subname = sub.OpenSubKey(str);
                foreach (string sSubname in subname.GetValueNames())
                {
                    listBox1.Items.Add(sSubname + " 值: " + subname.GetValue(sSubname));
                }
            }

        }
    }
}

 

读写注册表 registrykey 创建删除

标签:

原文地址:http://www.cnblogs.com/rogge7/p/5472187.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!