Search notes:

Microsoft.Win32.RegistryKey (class)

Methods and properties

Close()
CreateSubKey()
DeleteSubKey()
DeleteSubKeyTree()
DeleteValue()
Dispose()
Flush()
FromHandle()
GetAccessControl() Returns a System.Security.AccessControl.RegistrySecurity object which represents the Windows access control security for the registry key.
GetSubKeyNames() Returns an array of strings that correspond to the names of the registry key's sub keys.
GetValue() Returns a given registry value's value
GetValueKind() Returns the value's Microsoft.Win32.RegistryValueKind enum.
GetValueNames() Returns an array of strings that correspond to the names of the registry key's values.
Handle
Name The absolute (qualified) name of the registry key.
OpenBaseKey() This static method opens a hive.
OpenRemoteBaseKey()
OpenSubKey()
SetAccessControl()
SetValue()
SubKeyCount
ToString()
ValueCount
View An entry of the Microsoft.Win32.RegistryView enum which indicates which view was used to create the registry key. There are (currently) two values only: Registry32 and Registry64.

C-Sharp: read value from registry

A given registry key is represented by an instance of a Microsoft.Win32.RegistryKey type. The reference to a key is obtained by calling CreateSubKey(keyName), even if the key already exists. This is demonstrated by the following example.
The example reads the value of PATH in the registry keys HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and HKEY_CURRENT_USER\Environment. These values contain the Windows environment variables, separated by a semicolon.
Therefore, the values are split with the String.Split() method and individually printed to the Console.
Because a user might not have the necessary rights to access HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment, the respective access is guarded by a try … catch block that specifically catches UnauthorizedAccessException.
using System;
using Microsoft.Win32;

class ReadPath {

   private static void printPaths(RegistryKey key) {

      foreach (string path in (key.GetValue("PATH") as string).Split(new char[] {';'})) {
         Console.WriteLine($"  {path}");
      }
   }

   public static void Main() {

      try {
         Console.WriteLine("Global Env");
         RegistryKey globalEnv = Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Control\Session Manager\Environment");
         printPaths(globalEnv);
      }
      catch (UnauthorizedAccessException) {
         Console.WriteLine("  Not enough permission to access Environment Key of HKLM");
      }

      RegistryKey userEnv   = Registry.CurrentUser.CreateSubKey(@"Environment");
      Console.WriteLine("User Env");
      printPaths(userEnv);

   }
}
Github repository .NET-API, path: /Microsoft/Win32/RegistryKey/readPath.cs

PowerShell: get-item registryKey

Microsoft.Win32.RegistryKey is the class that is returned by the get-item for registry keys.
PS C:\> $regKey = get-item HKCU:\Environment
PS C:\> $regKey.GetType().FullName
Microsoft.Win32.RegistryKey
PS C:\> $regKey.getValue('PATH')

Index