API Reference
RegistryReader
Helpers for reading Windows Registry values and keys (local or remote). Includes typed getters, kind-explicit conversion, Ensure* (throwing) methods, and alias expansion for user hives.
Inheritance
- Object
- RegistryReader
Methods
public static T Ensure<T>(String computer, String fullPath, String valueName, RegistryValueKind expectedKind, Boolean expandEnv = false) #TType Parameters
- T
Parameters
- computer String
- fullPath String
- valueName String
- expectedKind RegistryValueKind
- expandEnv Boolean = false
public static Byte[] EnsureBinary(String computer, String fullPath, String valueName) #Byte[]Reads a REG_BINARY or throws when missing/unreadable.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
public static Int32 EnsureDword(String computer, String fullPath, String valueName) #Int32Reads a REG_DWORD or throws when missing/unreadable.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
public static String[] EnsureMultiString(String computer, String fullPath, String valueName) #String[]Reads a REG_MULTI_SZ or throws when missing/unreadable.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
public static Int64 EnsureQword(String computer, String fullPath, String valueName) #Int64Reads a REG_QWORD or throws when missing/unreadable.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
public static String EnsureString(String computer, String fullPath, String valueName, Boolean expandEnv = false) #StringReads a REG_SZ/REG_EXPAND_SZ as string or throws when missing/unreadable.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
- expandEnv System.Boolean = false
Ensure``1(System.String computer, System.String fullPath, System.String valueName, Microsoft.Win32.RegistryValueKind expectedKind, System.Boolean expandEnv) #Reads and converts a value to T, throwing on failure. Intended for must-exist settings.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
- expectedKind Microsoft.Win32.RegistryValueKind
- expandEnv System.Boolean
public static T Get<T>(String computer, String fullPath, String valueName = null, Boolean expandEnv = false) #TReads and converts a value to an expected kind (e.g., REG_DWORD → int, REG_BINARY → byte[]). Returns null on missing/unreadable/incompatible data.
Type Parameters
- T
Parameters
- computer System.String
- fullPath System.String
- valueName System.String = null
- expectedKind Microsoft.Win32.RegistryValueKind = false
- expandEnv System.Boolean = false
public static Task<T> GetAsync<T>(String computer, String fullPath, String valueName = null, Boolean expandEnv = false, CancellationToken ct = null) #Task<T>Type Parameters
- T
Parameters
- computer String
- fullPath String
- valueName String = null
- expandEnv Boolean = false
- ct CancellationToken = null
GetAsync``1(System.String computer, System.String fullPath, System.String valueName, System.Boolean expandEnv, System.Threading.CancellationToken ct) #Async convenience wrapper for Boolean); runs on the thread pool and supports cancellation.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
- expandEnv System.Boolean
- ct System.Threading.CancellationToken
public static Byte[] GetBinary(String computer, String fullPath, String valueName) #Byte[]Reads a REG_BINARY value.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
public static Nullable<Int32> GetDword(String computer, String fullPath, String valueName) #Nullable<Int32>Reads a REG_DWORD value.
Parameters
- computer System.String
- Target host.
- fullPath System.String
- Absolute key path.
- valueName System.String
- Value name.
public static String[] GetMultiString(String computer, String fullPath, String valueName) #String[]Reads a REG_MULTI_SZ value.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
public static T GetOrDefault<T>(String computer, String fullPath, String valueName, T defaultValue, Boolean expandEnv = false) #TType Parameters
- T
Parameters
- computer String
- fullPath String
- valueName String
- defaultValue T
- expandEnv Boolean = false
GetOrDefault``1(System.String computer, System.String fullPath, System.String valueName, ``0 defaultValue, System.Boolean expandEnv) #Reads a value and converts it to T, or returns a default when missing/unreadable.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
- defaultValue ``0
- expandEnv System.Boolean
public static Nullable<Int64> GetQword(String computer, String fullPath, String valueName) #Nullable<Int64>Reads a REG_QWORD value.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
public static String GetString(String computer, String fullPath, String valueName, Boolean expandEnv = false) #StringReads a REG_SZ or REG_EXPAND_SZ value.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
- expandEnv System.Boolean = false
Get``1(System.String computer, System.String fullPath, System.String valueName, System.Boolean expandEnv) #Reads a value and converts it to T; returns null/default on failure.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
- expandEnv System.Boolean
public static KeyDump ReadKey(String computer, String fullPath, Boolean advanced = false, Boolean expandEnv = false, Boolean adjustAcl = false) #KeyDumpDumps all values and subkeys under a given key. Non-throwing: returns Success=false on failure.
Parameters
- computer System.String
- Target computer name or '.'.
- fullPath System.String
- Absolute registry path such as HKLM\... or HKU\SID\...
- advanced System.Boolean = false
- When true, includes registry metadata; currently unused.
- expandEnv System.Boolean = false
- When true, expands REG_EXPAND_SZ values.
- adjustAcl System.Boolean = false
- When true, temporarily grants Administrators RW access to the key on access denied.
public static Task<KeyDump> ReadKeyAsync(String computer, String fullPath, Boolean advanced = false, Boolean expandEnv = false, CancellationToken ct = null) #Task<KeyDump>Async convenience wrapper for Boolean); runs on the thread pool and supports cancellation.
Parameters
- computer System.String
- fullPath System.String
- advanced System.Boolean = false
- expandEnv System.Boolean = false
- ct System.Threading.CancellationToken = null
public static IEnumerable<KeyDump> ReadKeyExpanded(String computer, String fullPath, Boolean advanced = false, Boolean expandEnv = false) #IEnumerable<KeyDump>Reads a key (values and subkeys) with alias expansion (HKUA/HKUD/HKUO etc.). Returns one dump per expanded target; automatically mounts/unmounts offline hives.
Parameters
- computer System.String
- fullPath System.String
- advanced System.Boolean = false
- expandEnv System.Boolean = false
public static ValueResult ReadValue(String computer, String fullPath, String valueName = null, Boolean expandEnv = false, Boolean adjustAcl = false) #ValueResultReads a single registry value. Non-throwing: returns Success=false and an Error string on failure.
Parameters
- computer System.String
- Target computer ("." or machine name).
- fullPath System.String
- Absolute path like HKLM\Software\... or HKU\SID\...
- valueName System.String = null
- Value name (null or empty for (Default)).
- expandEnv System.Boolean = false
- When true, expands REG_EXPAND_SZ.
- adjustAcl System.Boolean = false
- When true, temporarily grants Administrators RW access to the key on access denied.
public static Task<ValueResult> ReadValueAsync(String computer, String fullPath, String valueName = null, Boolean expandEnv = false, CancellationToken ct = null) #Task<ValueResult>Async convenience wrapper for Boolean); runs on the thread pool and supports cancellation.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String = null
- expandEnv System.Boolean = false
- ct System.Threading.CancellationToken = null
public static IEnumerable<ValueResult> ReadValueExpanded(String computer, String fullPath, String valueName = null, Boolean expandEnv = false) #IEnumerable<ValueResult>Reads a single value with alias expansion (HKUA/HKUD/HKUO etc.). Returns one result per expanded target; automatically mounts/unmounts offline hives.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String = null
- expandEnv System.Boolean = false
public static IEnumerable<ValueResult> ReadValueMany(IEnumerable<String> computers, String fullPath, String valueName = null, Boolean expandEnv = false, Int32 maxConcurrency = 16) #IEnumerable<ValueResult>Reads a value across many computers in parallel.
Parameters
- computers System.Collections.Generic.IEnumerable{System.String}
- fullPath System.String
- valueName System.String = null
- expandEnv System.Boolean = false
- maxConcurrency System.Int32 = 16
public static Boolean TryGetBinary(String computer, String fullPath, String valueName, out Byte[] value) #BooleanTries to read a REG_BINARY value.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
- value System.Byte[]@
public static Boolean TryGetDword(String computer, String fullPath, String valueName, out Int32 value) #BooleanTries to read a REG_DWORD value.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
- value System.Int32@
public static Boolean TryGetMultiString(String computer, String fullPath, String valueName, out String[] value) #BooleanTries to read a REG_MULTI_SZ value.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
- value System.String[]@
public static Boolean TryGetQword(String computer, String fullPath, String valueName, out Int64 value) #BooleanTries to read a REG_QWORD value.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
- value System.Int64@
public static Boolean TryGetString(String computer, String fullPath, String valueName, out String value, Boolean expandEnv = false) #BooleanTries to read a REG_SZ/REG_EXPAND_SZ value.
Parameters
- computer System.String
- fullPath System.String
- valueName System.String
- value System.String@
- expandEnv System.Boolean = false
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
Properties
public static RegistryView DefaultView { get; set; } #Gets or sets the default registry view used for all local and remote opens (HKLM/HKU). Defaults to Registry64 on 64‑bit operating systems and to Registry32 otherwise. Change when callers need the alternate registry view (for example, forcing the 32‑bit view on a 64‑bit host).