HELP! Registry Functions in C#.NET


// C# 
Microsoft.Win32.RegistryKey REGKEY; 
string sVal; 

REGKEY = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("PathofKey"); 
//open a string value from the registry 
sVal = (string) REGKEY.GetValue("NameOfValue",(object)"DefaultReturn");

To change registry values:


// C# 

Object oVal; 
Microsoft.Win32.RegistryKey REGKEY; 
oVal = "NewValue"; 
//the true on the end of the call makes the registry entry writable 
REGKEY = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("KeyToOpen",true); 
REGKEY.SetValue("NewValName",oVal);