namespacewindowsformsapplication1{ Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); } Private voidForm1_Load (Objectsender, 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(stringStrinchSub. Getsubkeynames ()) {LISTBOX1.ITEMS.ADD ("subkey Name:"+str); RegistryKey SubName=Sub. OpenSubKey (str); foreach(stringSsubnameinchSubName. GetValueNames ()) {LISTBOX1.ITEMS.ADD (Ssubname+"values:"+SubName. GetValue (Ssubname)); } } } Private voidButton1_Click (Objectsender, EventArgs e) { This. ListBox1.Items.Clear (); RegistryKey ABC=Registry.localmachine; RegistryKey Sub= ABC. OpenSubKey (@"Software",true);//PermissionsSub. Deletesubkeytree ("clp2016test");//Delete foreach(stringStrinchSub. Getsubkeynames ()) {LISTBOX1.ITEMS.ADD ("subkey Name:"+str); RegistryKey SubName=Sub. OpenSubKey (str); foreach(stringSsubnameinchSubName. GetValueNames ()) {LISTBOX1.ITEMS.ADD (Ssubname+"values:"+SubName. GetValue (Ssubname)); } } } }}
Read and write registry RegistryKey Create delete