Here is a quick example on how to access the registry in .NET. This example just loops thru each entry in the selected folder in the registry and prints the gathered information to the console.
using System;using Microsoft.Win32;namespace Acessing_Registry{ class AccessingRegistry { [STAThread] static void Main(string[] args) { //create a object that would reference to the parent registry type folder RegistryKey regKey = Registry.LocalMachine; //assign a path in the registry to read regKey = regKey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"); //loop thru each entry in the registry foreach(string keyName in regKey.GetValueNames()) { //read and display that keyName's value Console.WriteLine(keyName + ":" + regKey.GetValue(keyName)); } //display the output to the screen Console.ReadLine(); } }}
The important thing to note on this example is that we first declare the location on where to read the key and reference that key by its name to get the underlying value/s.
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.