[C#] 读写注册表

RegistryKey   rkey   =   Registry.LocalMachine;  
  //The   second   parameter   tells   it   to   open   the   key   as   writable  
          RegistryKey rkey1   =   rkey.OpenSubKey("Software",true);  
  RegistryKey   rkey2   =   rkey1.CreateSubKey("baoTest");  
  rkey2.SetValue("Name",textBox1.Text);  
  rkey2.Close();  
  rkey1.Close();  
  读:  
  RegistryKey   rkey   =   Registry.LocalMachine;  
  //The   second   parameter   tells   it   to   open   the   key   as   writable  
  RegistryKey rkey1   =   rkey.OpenSubKey("Software\\baoTest",true);  
  textBox2.Text=rkey1.GetValue("Name").ToString();  
posted on 2010-05-10 09:35  BoneKing  阅读(153)  评论(0编辑  收藏  举报