Search

Read a Registry key

This C# code snippet reads a key from the Windows Registry.
using Microsoft.Win32;

RegistryKey masterKey = Registry.LocalMachine.CreateSubKey 
   ("SOFTWARE\\Test\\customkey");
if (masterKey == null)
{
   Console.WriteLine ("Null Masterkey!");
}
else
{
   Console.WriteLine ("MyKey = {0}", masterKey.GetValue ("MyKey"));
}
masterKey.Close();