Read a Registry key
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
| C# Code Snippets |
| See also |
| edit |
This C# code snippet reads a key from the Windows Registry.
WARNING: DO NOT PLAY WITH THE REGISTRY. If you do not know what you are doing, you can cause any number of costly problems. Use this code at your own risk.
using Microsoft.Win32; ... RegistryKey masterKey = Registry.LocalMachine.CreateSubKey ("SOFTWARE\\Test\\Preferences"); if (masterKey == null) { Console.WriteLine ("Null Masterkey!"); } else { Console.WriteLine ("MyKey = {0}", masterKey.GetValue ("MyKey")); } masterKey.Close();