// Write registry registry registryKey regWrite; // Write a Sub key named "TEST" in the HKEY_CURRENT_USER key key // If the Test subkey already exists, it will automatically overwrite it REGWRITE = Registry.currentuser.createSubkey "Software // Test"); // Add two data items to the TEST sub-key, one name "name", another name "sex" // value is "Luolie", "Men" RegWrite.SetValue ("Name", "Luolie"); RegWrite.SetValue ("SEX", "Men"); // Close the object regWrite.close ();
Read the registry registryKey regread; // read the Software sub-key in the hkey_current_user key key regread = registry.currentuser.OpenSubkey ("Software // Test", true); if (regread == null ) // If the subkey does not exist {messagebox.show ("no data!");} Else {Object obj = regread.getValue ("name"); // read the value of the "name" item textBox1.text = Obj.toString (); // Displayed in TextBox} // Close the object oreg.close ();