C# > Win32 > RegistryKey
RegistryKey represents a key-level node in the Windows registry
Example:
Save user name to registry
RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("MyProgram");
if (regKey == null)
regKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("MyProgram");
if (regKey.GetValue("User", "") == null)
{
regKey.SetValue("User", txtUser.Text);
}
else
{
if (txtUser.Text != regKey.GetValue("User", "").ToString())
{
regKey.SetValue("User", txtUser.Text);
}
}
regKey.Close();