Reading and writing to a registry is a routine task that an application developer has to perform using the C# code. Here is a handy way to read/write Windows registry using the C# code.
Required namespace:
using Microsoft.Win32;
Simple Way to Read/Write Registry:
public string GetRegistryValue(string key)
{
return Convert.ToString(Registry.GetValue
(@"HKEY_CURRENT_USER\Software\Yahoo\Common", "Sandy", "OLD"));
}
public void SetRegistryValue()
{
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Yahoo\Common", "Sandy", NEW");
}
The above given is a simple method for accessing the registry. More complex class can be written to leverage advance registry functionality.
3 comments:
Thanks
Thanks!
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Yahoo\Common", "Sandy", NEW");
is missing a " before NEW
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Yahoo\Common", "Sandy", NEW");
missing a " before NEW
Post a Comment