Loading and saving registry information in C#

Saving info to the registry for the currently logged in user:

RegistryKey key = Registry.CurrentUser.CreateSubKey("MyRegistryKey");
key.SetValue("MyKeyValue", "Some value");

Loading the same info from the registry:

RegistryKey key = Registry.CurrentUser.CreateSubKey("MyRegistryKey");
if(key != null) {
    string keyValue = (string) key .GetValue("MyKeyValue");
}

Reference:
RegistryKey Class MSDN documentation

Posted on 08 Nov 04 by Helen Emerson (last updated on 08 Nov 04).
Filed under .NET