using Microsoft.Win32; RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\MyApp"); if (key != null) { string value = (string)key.GetValue("SettingKey"); Console.WriteLine(value); key.Dispose(); }
using Microsoft.Win32; RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\MyApp"); if (key != null) { key.SetValue("SettingKey", "NewValue"); key.Dispose(); }In this example, we are creating a new registry key under the CurrentUser hive and setting the value of a specific setting. We call Dispose to free up the resources used by the key when finished. Package/library: Microsoft.Win32.Registry