Base Framework
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
extension::RegistryKey Class Reference

Registry key. More...

#include <base/extension/dk.sdu.mip/win32/Registry.h>

Inherits Object.

Public Types

enum  Root {
  CLASSES, MACHINE, USER, USERS,
  SYSTEM
}
 
enum  ValueType {
  UNSUPPORTED_VALUE, UNSPECIFIED_VALUE, BINARY_VALUE, INTEGER_VALUE,
  INTEGER_BE_VALUE, INTEGER_64_VALUE, LINK_VALUE, RESOURCE_LIST_VALUE,
  ENVIRONMENT_STRING_VALUE, STRING_SEQUENCE_VALUE, STRING_VALUE
}
 
enum  Access { READ, WRITE, READWRITE }
 

Public Member Functions

 RegistryKey () noexcept
 
 RegistryKey (const RegistryKey &copy) noexcept
 
RegistryKeyoperator= (const RegistryKey &assign) noexcept
 
 RegistryKey (const String &machine, Root root, const String &path, Access access)
 
 RegistryKey (Root root, const String &path, Access access)
 
RegistryKey open (const String &name, Access access) const
 
RegistryKey addSubkey (const String &name, Access access)
 
void close ()
 
bool isValid () const
 
Array< StringgetKeys ()
 
Array< StringgetValues () const
 
bool isEmpty () const
 
bool isKey (const String &name) const
 
bool isValue (const String &name) const
 
Date getLastModification () const
 
Trustee getOwner () const
 
Trustee getGroup () const
 
AccessControlList getACL () const
 
void setACL (const AccessControlList &acl)
 
AnyValue getValue (const String &name) const
 
void setValue (const String &name, const AnyValue &value) const
 
uint32 getInteger (const String &name) const
 
void setInteger (const String &name, uint32 value)
 
String getBinary (const String &name) const
 
void setBinary (const String &name, const char *buffer, unsigned int size)
 
String getString (const String &name) const
 
void setValue (const String &name, const String &value)
 
Array< StringgetStringSequence (const String &name) const
 
void setValue (const String &name, const Array< String > &value)
 
void flush ()
 
bool removeKey (const String &name, bool force=false)
 
bool removeValue (const String &name)
 
ValueType getTypeOfValue (const String &name) const
 
unsigned int getSize (const String &name) const
 

Static Public Member Functions

static RegistryKey getMachine ()
 
static RegistryKey getUser ()
 

Detailed Description

Registry key.

This class provides access to the Registry on Windows platforms. This class is an extension component of the Base Framework and is only available for WIN32 platforms.

Version
1.0

Member Enumeration Documentation

◆ Access

Enumerator
READ 

Read access.

WRITE 

Write access.

READWRITE 

Read and write access.

◆ Root

Registry root.

Enumerator
CLASSES 

The classes registry.

MACHINE 

The registry of the local machine.

USER 

The registry of the current user.

USERS 

The registry of the users.

SYSTEM 

The default registry for new users.

◆ ValueType

The type of a value within the Registry.

Enumerator
UNSUPPORTED_VALUE 

Value type is not supported.

UNSPECIFIED_VALUE 

Value type is unspecified.

BINARY_VALUE 

Unspecified binary data.

INTEGER_VALUE 

A 32 bit integer in little endian byte order.

INTEGER_BE_VALUE 

A 32 bit integer in big endian byte order.

INTEGER_64_VALUE 

A 64 bit integer in little endian byte order.

LINK_VALUE 

A link.

RESOURCE_LIST_VALUE 

Device driver resource list.

ENVIRONMENT_STRING_VALUE 

String possibly containing references to environment variables.

STRING_SEQUENCE_VALUE 

A sequence of strings.

STRING_VALUE 

String value.

Constructor & Destructor Documentation

◆ RegistryKey() [1/4]

extension::RegistryKey::RegistryKey ( )
noexcept

Initializes key as invalid.

◆ RegistryKey() [2/4]

extension::RegistryKey::RegistryKey ( const RegistryKey copy)
inlinenoexcept

Initialization of handle from other handle.

◆ RegistryKey() [3/4]

extension::RegistryKey::RegistryKey ( const String machine,
Root  root,
const String path,
Access  access 
)

Opens the specified Registry key on a remote machine.

Parameters
machineThe machine (e.g. "\\machine").
rootThe Registry root (e.g. MACHINE).
pathThe path of the key within the specified root.
accessThe desired access (i.e. READ, WRITE, READWRITE).

◆ RegistryKey() [4/4]

extension::RegistryKey::RegistryKey ( Root  root,
const String path,
Access  access 
)

Opens the specified Registry key.

Parameters
rootThe Registry root (e.g. MACHINE).
pathThe path of the key within the specified root.
accessThe desired access (i.e. READ, WRITE, READWRITE).

Member Function Documentation

◆ addSubkey()

RegistryKey extension::RegistryKey::addSubkey ( const String name,
Access  access 
)

Adds a new subkey.

Parameters
nameThe name of the subkey.
accessThe desired access (i.e. READ, WRITE, READWRITE).

◆ close()

void extension::RegistryKey::close ( )

Closes the handle to this key.

◆ flush()

void extension::RegistryKey::flush ( )

Flushes any cached data to the Registry.

◆ getACL()

AccessControlList extension::RegistryKey::getACL ( ) const

Returns the ACL for the key.

◆ getBinary()

String extension::RegistryKey::getBinary ( const String name) const

Returns the value of a binary value (i.e. BINARY_VALUE and UNSPECIFIED_VALUE).

Parameters
nameThe name of the value.

◆ getGroup()

Trustee extension::RegistryKey::getGroup ( ) const

Returns the primary group of the key.

◆ getInteger()

uint32 extension::RegistryKey::getInteger ( const String name) const

Returns the value of a 32 bit integer value (either INTEGER_VALUE or INTEGER_BE_VALUE)

◆ getKeys()

Array<String> extension::RegistryKey::getKeys ( )

Returns the names of the subkeys within the key.

◆ getLastModification()

Date extension::RegistryKey::getLastModification ( ) const

Returns the last modification time of the key.

◆ getMachine()

static RegistryKey extension::RegistryKey::getMachine ( )
static

Returns a handle to the Registry of the local machine.

◆ getOwner()

Trustee extension::RegistryKey::getOwner ( ) const

Returns the owner of the key.

◆ getSize()

unsigned int extension::RegistryKey::getSize ( const String name) const

Returns the size of the specified value.

Parameters
nameThe name of the value.

◆ getString()

String extension::RegistryKey::getString ( const String name) const

Returns the value of a string value (i.e. STRING_VALUE or ENVIRONMENT_STRING_VALUE).

◆ getStringSequence()

Array<String> extension::RegistryKey::getStringSequence ( const String name) const

Returns the strings of a multi string value.

Parameters
nameThe name of the Registry value.

◆ getTypeOfValue()

ValueType extension::RegistryKey::getTypeOfValue ( const String name) const

Returns the type of the specified key or value.

Parameters
nameThe name of the value.

◆ getUser()

static RegistryKey extension::RegistryKey::getUser ( )
static

Returns a handle to the personal Registry of the current user.

◆ getValue()

AnyValue extension::RegistryKey::getValue ( const String name) const

Returns the content of the specified value.

Parameters
nameThe name of the value.

◆ getValues()

Array<String> extension::RegistryKey::getValues ( ) const

Returns the names of the values within the key.

◆ isEmpty()

bool extension::RegistryKey::isEmpty ( ) const

Returns true if this key is empty.

◆ isKey()

bool extension::RegistryKey::isKey ( const String name) const

Returns true if the specified entry exists and is a key.

◆ isValid()

bool extension::RegistryKey::isValid ( ) const

Returns true if the handle is valid.

◆ isValue()

bool extension::RegistryKey::isValue ( const String name) const

Returns true if the specified entry exists and is a value.

◆ open()

RegistryKey extension::RegistryKey::open ( const String name,
Access  access 
) const

Returns a handle to the specified subkey of this key.

Parameters
nameThe name of the subkey.
accessThe desired access (i.e. READ, WRITE, READWRITE).

◆ operator=()

RegistryKey& extension::RegistryKey::operator= ( const RegistryKey assign)
inlinenoexcept

Assignment of handle by handle.

◆ removeKey()

bool extension::RegistryKey::removeKey ( const String name,
bool  force = false 
)

Removes the specified subkey.

Parameters
nameThe name of the key to remove.
forceSpecifies if true to remove the even if not empty. The default is false.
Returns
True if key was removed.

◆ removeValue()

bool extension::RegistryKey::removeValue ( const String name)

Removes the specified value from this key.

Parameters
nameThe name of the value.
Returns
True if value was removed.

◆ setACL()

void extension::RegistryKey::setACL ( const AccessControlList acl)

Sets the ACL of the key.

◆ setBinary()

void extension::RegistryKey::setBinary ( const String name,
const char *  buffer,
unsigned int  size 
)

Sets the value as a binary value (BINARY_VALUE).

Parameters
nameThe name of the value.
bufferThe source of the value content.
sizeThe number of bytes in the buffer.

◆ setInteger()

void extension::RegistryKey::setInteger ( const String name,
uint32  value 
)

Sets the value as a 32 bit integer (INTEGER_VALUE).

Parameters
nameThe name of the value.
contentThe content of the value.

◆ setValue() [1/3]

void extension::RegistryKey::setValue ( const String name,
const AnyValue value 
) const

Returns the content of the specified value.

Parameters
nameThe name of the value.
valueThe content of the Registry value.

◆ setValue() [2/3]

void extension::RegistryKey::setValue ( const String name,
const Array< String > &  value 
)

Sets the content of a multi string value.

Parameters
nameThe name of the Registry value.
valueThe desired mutil string content of the value.

◆ setValue() [3/3]

void extension::RegistryKey::setValue ( const String name,
const String value 
)

Sets the value of a string value (STRING_VALUE).

Parameters
nameThe name of the Registry value.
valueThe desired content of the value.