Reading Registry from C#

Learn to read the registry of the local machine from your C# code from your .net application running on the local machine.

Code Snippet
  1. using Microsoft.Win32;
  2. ...
  3. RegistryKey masterKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Test\\Preferences");
  4. if (masterKey == null)
  5. {
  6.     Console.WriteLine ("Null Masterkey!");
  7. }
  8. else
  9. {
  10.     Console.WriteLine ("MyKey = {0}", masterKey.GetValue ("MyKey"));
  11. }
  12. masterKey.Close();

Post a Comment