TestimoX

API Reference

Class

RegistryReader

Namespace ComputerX.Registry
Assembly ComputerX
Modifiers static

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) #
Returns: T

Type Parameters

T

Parameters

computer String requiredposition: 0
fullPath String requiredposition: 1
valueName String requiredposition: 2
expectedKind RegistryValueKind requiredposition: 3
expandEnv Boolean = false optionalposition: 4
public static Byte[] EnsureBinary(String computer, String fullPath, String valueName) #
Returns: Byte[]

Reads a REG_BINARY or throws when missing/unreadable.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String requiredposition: 2
public static Int32 EnsureDword(String computer, String fullPath, String valueName) #
Returns: Int32

Reads a REG_DWORD or throws when missing/unreadable.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String requiredposition: 2
public static String[] EnsureMultiString(String computer, String fullPath, String valueName) #
Returns: String[]

Reads a REG_MULTI_SZ or throws when missing/unreadable.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String requiredposition: 2
public static Int64 EnsureQword(String computer, String fullPath, String valueName) #
Returns: Int64

Reads a REG_QWORD or throws when missing/unreadable.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String requiredposition: 2
public static String EnsureString(String computer, String fullPath, String valueName, Boolean expandEnv = false) #
Returns: String

Reads a REG_SZ/REG_EXPAND_SZ as string or throws when missing/unreadable.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String requiredposition: 2
expandEnv System.Boolean = false optionalposition: 3
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 required
fullPath System.String required
valueName System.String required
expectedKind Microsoft.Win32.RegistryValueKind required
expandEnv System.Boolean required
public static T Get<T>(String computer, String fullPath, String valueName = null, Boolean expandEnv = false) #
Returns: T

Reads 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 requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String = null optionalposition: 2
expectedKind Microsoft.Win32.RegistryValueKind = false optionalposition: 3
expandEnv System.Boolean = false optionalposition: 4
public static Task<T> GetAsync<T>(String computer, String fullPath, String valueName = null, Boolean expandEnv = false, CancellationToken ct = null) #
Returns: Task<T>

Type Parameters

T

Parameters

computer String requiredposition: 0
fullPath String requiredposition: 1
valueName String = null optionalposition: 2
expandEnv Boolean = false optionalposition: 3
ct CancellationToken = null optionalposition: 4
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 required
fullPath System.String required
valueName System.String required
expandEnv System.Boolean required
ct System.Threading.CancellationToken required
public static Byte[] GetBinary(String computer, String fullPath, String valueName) #
Returns: Byte[]

Reads a REG_BINARY value.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String requiredposition: 2
public static Nullable<Int32> GetDword(String computer, String fullPath, String valueName) #
Returns: Nullable<Int32>

Reads a REG_DWORD value.

Parameters

computer System.String requiredposition: 0
Target host.
fullPath System.String requiredposition: 1
Absolute key path.
valueName System.String requiredposition: 2
Value name.
public static String[] GetMultiString(String computer, String fullPath, String valueName) #
Returns: String[]

Reads a REG_MULTI_SZ value.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String requiredposition: 2
public static T GetOrDefault<T>(String computer, String fullPath, String valueName, T defaultValue, Boolean expandEnv = false) #
Returns: T

Type Parameters

T

Parameters

computer String requiredposition: 0
fullPath String requiredposition: 1
valueName String requiredposition: 2
defaultValue T requiredposition: 3
expandEnv Boolean = false optionalposition: 4
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 required
fullPath System.String required
valueName System.String required
defaultValue ``0 required
expandEnv System.Boolean required
public static Nullable<Int64> GetQword(String computer, String fullPath, String valueName) #
Returns: Nullable<Int64>

Reads a REG_QWORD value.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String requiredposition: 2
public static String GetString(String computer, String fullPath, String valueName, Boolean expandEnv = false) #
Returns: String

Reads a REG_SZ or REG_EXPAND_SZ value.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String requiredposition: 2
expandEnv System.Boolean = false optionalposition: 3
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 required
fullPath System.String required
valueName System.String required
expandEnv System.Boolean required
public static KeyDump ReadKey(String computer, String fullPath, Boolean advanced = false, Boolean expandEnv = false, Boolean adjustAcl = false) #
Returns: KeyDump

Dumps all values and subkeys under a given key. Non-throwing: returns Success=false on failure.

Parameters

computer System.String requiredposition: 0
Target computer name or '.'.
fullPath System.String requiredposition: 1
Absolute registry path such as HKLM\... or HKU\SID\...
advanced System.Boolean = false optionalposition: 2
When true, includes registry metadata; currently unused.
expandEnv System.Boolean = false optionalposition: 3
When true, expands REG_EXPAND_SZ values.
adjustAcl System.Boolean = false optionalposition: 4
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) #
Returns: Task<KeyDump>

Async convenience wrapper for Boolean); runs on the thread pool and supports cancellation.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
advanced System.Boolean = false optionalposition: 2
expandEnv System.Boolean = false optionalposition: 3
ct System.Threading.CancellationToken = null optionalposition: 4
public static IEnumerable<KeyDump> ReadKeyExpanded(String computer, String fullPath, Boolean advanced = false, Boolean expandEnv = false) #
Returns: 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 requiredposition: 0
fullPath System.String requiredposition: 1
advanced System.Boolean = false optionalposition: 2
expandEnv System.Boolean = false optionalposition: 3
public static ValueResult ReadValue(String computer, String fullPath, String valueName = null, Boolean expandEnv = false, Boolean adjustAcl = false) #
Returns: ValueResult

Reads a single registry value. Non-throwing: returns Success=false and an Error string on failure.

Parameters

computer System.String requiredposition: 0
Target computer ("." or machine name).
fullPath System.String requiredposition: 1
Absolute path like HKLM\Software\... or HKU\SID\...
valueName System.String = null optionalposition: 2
Value name (null or empty for (Default)).
expandEnv System.Boolean = false optionalposition: 3
When true, expands REG_EXPAND_SZ.
adjustAcl System.Boolean = false optionalposition: 4
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) #
Returns: Task<ValueResult>

Async convenience wrapper for Boolean); runs on the thread pool and supports cancellation.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String = null optionalposition: 2
expandEnv System.Boolean = false optionalposition: 3
ct System.Threading.CancellationToken = null optionalposition: 4
public static IEnumerable<ValueResult> ReadValueExpanded(String computer, String fullPath, String valueName = null, Boolean expandEnv = false) #
Returns: 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 requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String = null optionalposition: 2
expandEnv System.Boolean = false optionalposition: 3
public static IEnumerable<ValueResult> ReadValueMany(IEnumerable<String> computers, String fullPath, String valueName = null, Boolean expandEnv = false, Int32 maxConcurrency = 16) #
Returns: IEnumerable<ValueResult>

Reads a value across many computers in parallel.

Parameters

computers System.Collections.Generic.IEnumerable{System.String} requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String = null optionalposition: 2
expandEnv System.Boolean = false optionalposition: 3
maxConcurrency System.Int32 = 16 optionalposition: 4
public static Boolean TryGetBinary(String computer, String fullPath, String valueName, out Byte[] value) #
Returns: Boolean

Tries to read a REG_BINARY value.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String requiredposition: 2
value System.Byte[]@ requiredposition: 3
public static Boolean TryGetDword(String computer, String fullPath, String valueName, out Int32 value) #
Returns: Boolean

Tries to read a REG_DWORD value.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String requiredposition: 2
value System.Int32@ requiredposition: 3
public static Boolean TryGetMultiString(String computer, String fullPath, String valueName, out String[] value) #
Returns: Boolean

Tries to read a REG_MULTI_SZ value.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String requiredposition: 2
value System.String[]@ requiredposition: 3
public static Boolean TryGetQword(String computer, String fullPath, String valueName, out Int64 value) #
Returns: Boolean

Tries to read a REG_QWORD value.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String requiredposition: 2
value System.Int64@ requiredposition: 3
public static Boolean TryGetString(String computer, String fullPath, String valueName, out String value, Boolean expandEnv = false) #
Returns: Boolean

Tries to read a REG_SZ/REG_EXPAND_SZ value.

Parameters

computer System.String requiredposition: 0
fullPath System.String requiredposition: 1
valueName System.String requiredposition: 2
value System.String@ requiredposition: 3
expandEnv System.Boolean = false optionalposition: 4

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).