juno.utils.registry Module

Contains classes that manipulate the Windows registry.

Licence
See licence.txt for use and distribution terms.

enum RegistryValueKind;

Specifies the data types to use when storing values in the registry.

Unknown

Indicates an unsupported registry data type.

String

Specifies a string. Equivalent to REG_SZ.

ExpandString

Specifies a string containing references to environment vaariables. Equivalent to REG_EXPAND_SZ.

Binary

Specifies binary data in any form. Equivalent to REG_BINARY.

DWord

Specifies a 32-bit binary number. Equivalent to REG_DWORD.

MultiString

Specifies an array of strings. Equivalent to REG_MULTI_SZ.

QWord

Specifies a 64-bit binary number. Equivalent to REG_QWORD.

enum RegistryValueOptions;



None



DoNotExpandEnvironmentNames



enum RegistryOptions;



None



Volatile



class RegistryKey;

Represents a node in the Windows registry.

Examples
 import juno.utils.registry, std.stdio;

 void main() {
   // Create a subkey named TestKey under "HKEY_CURRENT_USER".
   scope key = RegistryKey.currentUser.createSubKey("TestKey");
   if (key) {
     // Create data for the TestKey subkey.
     key.setValue("StringValue", "Hello, World");
     key.setValue("DWordValue", 123);
     key.setValue("BinaryValue", cast(ubyte[])[1, 2, 3]);
     key.setValue("MultiStringValue", ["Hello", "World"]);

     // Print the data in the TestKey subkey.
     writefln("There are %s values for %s", key.valueCount, key.name);
     foreach (valueName; key.valueNames) {
       writefln("%s: %s", valueName, key.getValue!(string)(valueName));
     }
   }
 }

static RegistryKey classesRoot();

Defines the types of documents and properties associated with those types. Reads HKEY_CLASSES_ROOT.

static RegistryKey currentUser();

Contains information about the current user preferences. Reads HKEY_CURRENT_USER.

static RegistryKey localMachine();

Contains configuration data for the local machine. Reads HKEY_LOCAL_MACHINE.

static RegistryKey users();

Contains information about the default user configuration. Reads HKEY_USERS.

static RegistryKey performanceData();

Contains performance information for software components. Reads HKEY_PERFORMANCE_DATA.

static RegistryKey currentConfig();

Contains configuration information about hardware that is not specifiec to the user. Reads HKEY_CURRENT_CONFIG.

static RegistryKey dynData();

Contains dynamic registry data. Reads HKEY_DYN_DATA.

static RegistryKey fromHandle(Handle handle);



void close();

Closes the key.

void flush();

Writes all attributes of the current key into the registry.

RegistryKey openSubKey(char[] name, bool writable = false);

Retrieves a subkey.

Parameters
char[] name
Name or path of the subkey to open.
bool writable
true if you need write access to the key.

Returns
The subkey requested, or null if the operation failed.

RegistryKey createSubKey(char[] name, bool writable, RegistryOptions options = cast(RegistryOptions)0);
RegistryKey createSubKey(char[] name);

Creates a new subkey or opens an existing subkey.

Parameters
char[] name
The name or path of the subkey to create or open.
bool writable
true if you need write access to the key.

Returns
The newly created subkey.

void deleteSubKey(char[] name, bool throwOnMissingSubKey = true);

Deletes the specified subkey.

Parameters
char[] name
The name of the subkey to delete.
bool throwOnMissingSubKey
true to raise an exception if the subkey does not exist.

void deleteSubKeyTree(char[] name);

Deletes a subkey and child subkeys recursively.

Parameters
char[] name
The name of the subkey to delete.

Throws
UnauthorizedAccessException if the user does not have the necessary rights.
ArgumentException if name does not specify a valid subkey.

void deleteValue(char[] name, bool throwOnMissingValue = true);

Deletes the specified value from this key.

Parameters
char[] name
The name of the value to delete.
bool throwOnMissingValue
true to raise an exception if the specified value does not exist.

RegistryValueKind getValueKind(char[] name);

Retrieves the registry data type of the value associated with the specified name.

Parameters
char[] name
The name of the value whose registry data type is to be retrieved.

Returns
A value representing the registry data type of the value associated with name.

T getValue(T)(string name, T defaultValue = T.init, RegistryValueOptions options = RegistryValueOptions.None);

Retrieves the value associated with the specified name.

Parameters
name
The name of the value to retrieve.
defaultValue
The value to return if name does not exist.
expandEnvironmentNames
Specify true to expand environment values.

Returns
The value associated with name, or defaultValue if name is not found.

void setValue(T)(string name, T value, RegistryValueKind valueKind = RegistryValueKind.Unknown);

Sets the value of a name/value pair in the registry key using the specified registry data type.

Parameters
name
The name of the value to be stored.
value
The data to be stored.
valueKind
The registry data type to use when storing the data.

char[] toString();

Retrieves a string representation of this key.

char[] name();

Retrieves the name of this key.

uint valueCount();

Retrieves the count of values in the key.

char[][] valueNames();

Retrieves an array of strings containing all the value names.

uint subKeyCount();

Retrieves the count of subkeys of the current key.

char[][] subKeyNames();

Retrieves an array of strings containing all the subkey names.

Handle handle();