luni, 25 august 2014

Read save data to Registry C# Example

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();

Niciun comentariu:

Trimiteți un comentariu