std.windows.registry

This library provides Win32 Registry facilities.

Types 11

classWin32Exception : WindowsException
Methods
int error() @property
Constructors
this(string message, string fn = __FILE__, size_t ln = __LINE__, Throwable next = null)
this(string message, int errnum, string fn = __FILE__, size_t ln = __LINE__, Throwable next = null)

Exception class thrown by the std.windows.registry classes.

Constructors
this(string message, string fn = __FILE__, size_t ln = __LINE__, Throwable next = null)Creates an instance of the exception.
this(string message, int error, string fn = __FILE__, size_t ln = __LINE__, Throwable next = null)Creates an instance of the exception, with the given.
enumREGSAM

Enumeration of the recognised registry access modes.

KEY_QUERY_VALUE = 0x0001Permission to query subkey data
KEY_SET_VALUE = 0x0002Permission to set subkey data
KEY_CREATE_SUB_KEY = 0x0004Permission to create subkeys
KEY_ENUMERATE_SUB_KEYS = 0x0008Permission to enumerate subkeys
KEY_NOTIFY = 0x0010Permission for change notification
KEY_CREATE_LINK = 0x0020Permission to create a symbolic link
KEY_WOW64_32KEY = 0x0200Enables a 64- or 32-bit application to open a 32-bit key
KEY_WOW64_64KEY = 0x0100Enables a 64- or 32-bit application to open a 64-bit key
KEY_WOW64_RES = 0x0300
KEY_READ = (STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & ~(SYNCHRONIZE)
KEY_WRITE = (STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & ~(SYNCHRONIZE)Combines the STANDARDRIGHTSREAD, KEYQUERYVALUE, KEYENUMERATESUBKEYS, and KEYNOTIFY access rights
KEY_EXECUTE = KEY_READ & ~(SYNCHRONIZE)Combines the STANDARDRIGHTSWRITE, KEYSETVALUE, and KEYCREATESUB_KEY access rights
KEY_ALL_ACCESS = (STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK) & ~(SYNCHRONIZE)Permission for read access
enumREG_VALUE_TYPE : DWORD

Enumeration of the recognised registry value types.

REG_UNKNOWN = - 1
REG_NONE = 0The null value type. (In practise this is treated as a zero-length binary array by the Win32 registry)
REG_SZ = 1A zero-terminated string
REG_EXPAND_SZ = 2A zero-terminated string containing expandable environment variable references
REG_BINARY = 3A binary blob
REG_DWORD = 4A 32-bit unsigned integer
REG_DWORD_LITTLE_ENDIAN = 4A 32-bit unsigned integer, stored in little-endian byte order
REG_DWORD_BIG_ENDIAN = 5A 32-bit unsigned integer, stored in big-endian byte order
REG_LINK = 6A registry link
REG_MULTI_SZ = 7A set of zero-terminated strings
REG_RESOURCE_LIST = 8A hardware resource list
REG_FULL_RESOURCE_DESCRIPTOR = 9A hardware resource descriptor
REG_RESOURCE_REQUIREMENTS_LIST = 10A hardware resource requirements list
REG_QWORD = 11A 64-bit unsigned integer
REG_QWORD_LITTLE_ENDIAN = 11A 64-bit unsigned integer, stored in little-endian byte order
classKey

This class represents a registry key.

Fields
HKEY m_hkey
string m_name
Methods
string name() @property @safe pure nothrow constThe name of the key
size_t keyCount() @property constThe number of sub keys.
KeySequence keys() @property @safe pureAn enumerable sequence of all the sub-keys of this key.
KeyNameSequence keyNames() @property @safe pureAn enumerable sequence of the names of all the sub-keys of this key.
size_t valueCount() @property constThe number of values.
ValueSequence values() @property @safe pureAn enumerable sequence of all the values of this key.
ValueNameSequence valueNames() @property @safe pureAn enumerable sequence of the names of all the values of this key.
Key createKey(string name, REGSAM access = REGSAM.KEY_ALL_ACCESS)Returns the named sub-key of this key.
Key getKey(string name, REGSAM access = REGSAM.KEY_READ)Returns the named sub-key of this key.
void deleteKey(string name, REGSAM access = cast(REGSAM) 0)Deletes the named key.
Value getValue(string name)Returns the named value. If `name` is the empty string, then the default value is returned.
void setValue(string name, uint value)Sets the named value with the given 32-bit unsigned integer value.
void setValue(string name, uint value, Endian endian)Sets the named value with the given 32-bit unsigned integer value, according to the desired byte-ordering.
void setValue(string name, ulong value)Sets the named value with the given 64-bit unsigned integer value.
void setValue(string name, string value)Sets the named value with the given string value.
void setValue(string name, string value, bool asEXPAND_SZ)Sets the named value with the given string value.
void setValue(string name, string[] value)Sets the named value with the given multiple-strings value.
void setValue(string name, byte[] value)Sets the named value with the given binary value.
void deleteValue(string name)Deletes the named value.
void flush()Flushes any changes to the key to disk.
Constructors
this(HKEY hkey, string name, bool created)
Destructors
classValue

This class represents a value of a registry key.

Fields
Key m_key
string m_name
Methods
string name() @property @safe pure nothrow constThe name of the value. If the value represents a default value of a key, which has no name, the returned string will be of zero length.
REG_VALUE_TYPE type() @property @safe pure nothrow constThe type of value.
string value_SZ() @property constObtains the current value of the value as a string. If the value's type is REGEXPANDSZ the returned value is <b>not</b> expanded; `valueEXPANDSZ` should be called
string value_EXPAND_SZ() @property constObtains the current value as a string, within which any environment variables have undergone expansion. This function works with the same value-types as `value_SZ`.
string[] value_MULTI_SZ() @property constObtains the current value as an array of strings.
uint value_DWORD() @property constObtains the current value as a 32-bit unsigned integer, ordered correctly according to the current architecture.
ulong value_QWORD() @property constObtains the value as a 64-bit unsigned integer, ordered correctly according to the current architecture.
byte[] value_BINARY() @property constObtains the value as a binary blob.
Constructors
this(Key key, string name, REG_VALUE_TYPE type)

Represents the local system registry.

Methods
Key classesRoot() @propertyReturns the root key for the HKEYCLASSESROOT hive
Key currentUser() @propertyReturns the root key for the HKEYCURRENTUSER hive
Key localMachine() @propertyReturns the root key for the HKEYLOCALMACHINE hive
Key users() @propertyReturns the root key for the HKEY_USERS hive
Key performanceData() @propertyReturns the root key for the HKEYPERFORMANCEDATA hive
Key currentConfig() @propertyReturns the root key for the HKEYCURRENTCONFIG hive
Key dynData() @propertyReturns the root key for the HKEYDYNDATA hive
Constructors

An enumerable sequence representing the names of the sub-keys of a registry Key.

Example: ---- Key key = ... foreach (string subkeyName; key.keyNames) { // using subkeyName } ----

Fields
Key m_key
Methods
size_t count() @property constThe number of keys.
string getKeyName(size_t index)The name of the key at the given index.
string opIndex(size_t index)The name of the key at the given index.
int opApply(scope int delegate(ref string name) dg)
Constructors
this(Key key)

An enumerable sequence representing the sub-keys of a registry Key.

Example: ---- Key key = ... foreach (Key subkey; key.keys) { // using subkey } ----

Fields
Key m_key
Methods
size_t count() @property constThe number of keys.
Key getKey(size_t index)The key at the given index.
Key opIndex(size_t index)The key at the given index.
int opApply(scope int delegate(ref Key key) dg)
Constructors
this(Key key)

An enumerable sequence representing the names of the values of a registry Key.

Example: ---- Key key = ... foreach (string valueName; key.valueNames) { // using valueName } ----

Fields
Key m_key
Methods
size_t count() @property constThe number of values.
string getValueName(size_t index)The name of the value at the given index.
string opIndex(size_t index)The name of the value at the given index.
int opApply(scope int delegate(ref string name) dg)
Constructors
this(Key key)

An enumerable sequence representing the values of a registry Key.

Example: ---- Key key = ... foreach (Value value; key.values) { // using value } ----

Fields
Key m_key
Methods
size_t count() @property constThe number of values
Value getValue(size_t index)The value at the given `index`.
Value opIndex(size_t index)The value at the given `index`.
int opApply(scope int delegate(ref Value value) dg)
Constructors
this(Key key)

Functions 24

fnvoid enforceSucc(LONG res, lazy string message, string fn = __FILE__, size_t ln = __LINE__)
private fnREGSAM compatibleRegsam(in REGSAM samDesired)
private fnbool haveWoW64Job(in REGSAM samDesired)Returns true, if we are in WoW64 mode and have WoW64 flags
private fnLONG regCloseKey(in HKEY hkey)
private fnvoid regFlushKey(in HKEY hkey)
private fnHKEY regCreateKey(in HKEY hkey, in string subKey, in DWORD dwOptions, in REGSAM samDesired, in LPSECURITY_ATTRIBUTES lpsa, out DWORD disposition)
private fnvoid regDeleteKey(in HKEY hkey, in string subKey, in REGSAM samDesired)
private fnvoid regDeleteValue(in HKEY hkey, in string valueName)
private fnHKEY regDup(HKEY hkey)
private fnLONG regEnumKeyName(in HKEY hkey, in DWORD index, ref wchar[] name, out DWORD cchName)
private fnLONG regEnumValueName(in HKEY hkey, in DWORD dwIndex, ref wchar[] name, out DWORD cchName)
private fnLONG regGetNumSubKeys(in HKEY hkey, out DWORD cSubKeys, out DWORD cchSubKeyMaxLen)
private fnLONG regGetNumValues(in HKEY hkey, out DWORD cValues, out DWORD cchValueMaxLen)
private fnREG_VALUE_TYPE regGetValueType(in HKEY hkey, in string name)
private fnHKEY regOpenKey(in HKEY hkey, in string subKey, in REGSAM samDesired)
private fnvoid regQueryValue(in HKEY hkey, string name, out string value, REG_VALUE_TYPE reqType)
private fnvoid regQueryValue(in HKEY hkey, in string name, out string[] value, REG_VALUE_TYPE reqType)
private fnvoid regQueryValue(in HKEY hkey, in string name, out uint value, REG_VALUE_TYPE reqType)
private fnvoid regQueryValue(in HKEY hkey, in string name, out ulong value, REG_VALUE_TYPE reqType)
private fnvoid regQueryValue(in HKEY hkey, in string name, out byte[] value, REG_VALUE_TYPE reqType)
private fnvoid regSetValue(in HKEY hkey, in string subKey, in REG_VALUE_TYPE type, in LPCVOID lpData, in DWORD cbData)
private fnvoid regProcessNthKey(Key key, scope void delegate(scope LONG delegate(DWORD, out string)) dg)
private fnvoid regProcessNthValue(Key key, scope void delegate(scope LONG delegate(DWORD, out string)) dg)