Poco::Util

class WinRegistryKey

Library: Util
Package: Windows
Header: Poco/Util/WinRegistryKey.h

Description

This class implements a convenient interface to the Windows Registry.

This class is only available on Windows platforms.

Member Summary

Member Functions: close, deleteKey, deleteValue, exists, getInt, getString, getStringExpand, handleFor, handleSetError, key, open, setInt, setString, setStringExpand, subKeys, type, values

Types

Keys

typedef std::vector < std::string > Keys;

Values

typedef std::vector < std::string > Values;

Enumerations

Type

REGT_NONE = 0

REGT_STRING = 1

REGT_STRING_EXPAND = 2

REGT_DWORD = 4

Constructors

WinRegistryKey

WinRegistryKey(
    const std::string & key
);

Creates the WinRegistryKey.

The key must start with one of the root key names like HKEY_CLASSES_ROOT, e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.

WinRegistryKey

WinRegistryKey(
    HKEY hRootKey,
    const std::string & subKey
);

Creates the WinRegistryKey.

Destructor

~WinRegistryKey

~WinRegistryKey();

Destroys the WinRegistryKey.

Member Functions

deleteKey

void deleteKey();

Deletes the key. The key must not have subkeys.

deleteValue

void deleteValue(
    const std::string & name
);

Deletes the value with the given name.

Throws a NotFoundException if the value does not exist.

exists

bool exists();

Returns true iff the key exists.

exists

bool exists(
    const std::string & name
);

Returns true iff the given value exists under that key.

getInt

int getInt(
    const std::string & name
);

Returns the numeric value (REG_DWORD) with the given name. An empty name denotes the default value.

Throws a NotFoundException if the value does not exist.

getString

std::string getString(
    const std::string & name
);

Returns the string value (REG_SZ) with the given name. An empty name denotes the default value.

Throws a NotFoundException if the value does not exist.

getStringExpand

std::string getStringExpand(
    const std::string & name
);

Returns the string value (REG_EXPAND_SZ) with the given name. An empty name denotes the default value. All references to environment variables (%VAR%) in the string are expanded.

Throws a NotFoundException if the value does not exist.

setInt

void setInt(
    const std::string & name,
    int value
);

Sets the numeric (REG_DWORD) value with the given name. An empty name denotes the default value.

setString

void setString(
    const std::string & name,
    const std::string & value
);

Sets the string value (REG_SZ) with the given name. An empty name denotes the default value.

setStringExpand

void setStringExpand(
    const std::string & name,
    const std::string & value
);

Sets the expandable string value (REG_EXPAND_SZ) with the given name. An empty name denotes the default value.

subKeys

void subKeys(
    Keys & keys
);

Appends all subKey names to keys.

type

Type type(
    const std::string & name
);

Returns the type of the key value.

values

void values(
    Values & vals
);

Appends all value names to vals;

close protected

void close();

handleFor protected static

static HKEY handleFor(
    const std::string & rootKey
);

handleSetError protected

void handleSetError(
    const std::string & name
);

key protected

std::string key() const;

key protected

std::string key(
    const std::string & valueName
) const;

open protected

void open();