using Microsoft.Win32 ; using System; using Microsoft.Win32 ; namespace ybsys ... { /**//// <summary> ///注册表操作 /// </summary> public class EditRegedit ...{ public EditRegedit() ...{ } /**//// <summary> /// 写注册表 /// </summary> public void writeReg() ...{ 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("WindowWinSys"); rkey2.SetValue("winyb","2007-8-9"); rkey2.Close(); rkey1.Close(); } /**//// <summary> /// 读注册表 /// </summary> /// <returns></returns> public string readReg() ...{ RegistryKey rkey = Registry.LocalMachine; //The second parameter tells it to open the key as writable RegistryKey rkey1 = rkey.OpenSubKey("Software/baoTest",true); //rkey1.GetValue("Name") if(rkey1==null||rkey1.GetValue("Name")==null) ...{ return ""; } else ...{ return rkey1.GetValue("Name").ToString(); } } }}