UTF8 - Simple Library for Internationalization
Loading...
Searching...
No Matches
Registry Functions

Wrappers for Windows registry functions. More...

Functions

LSTATUS utf8::RegCreateKey (HKEY key, const std::string &subkey, HKEY &result, DWORD options, REGSAM sam, const SECURITY_ATTRIBUTES *psa, DWORD *disp)
 Convenience wrapper for RegCreateKeyEx
 
LSTATUS utf8::RegOpenKey (HKEY key, const std::string &subkey, HKEY &result, REGSAM sam, bool link)
 Wrapper for RegOpenKeyEx
 
LSTATUS utf8::RegDeleteKey (HKEY key, const std::string &subkey, REGSAM sam)
 Wrapper for RegDeleteKeyEx or RegDeleteKey
 
LSTATUS utf8::RegDeleteValue (HKEY key, const std::string &value)
 Wrapper for RegDeleteValue
 
LSTATUS utf8::RegDeleteTree (HKEY key, const std::string &subkey)
 Wrapper for RegDeleteTree
 
LSTATUS utf8::RegRenameKey (HKEY key, const std::string &subkey, const std::string &new_name)
 Wrapper for RegRenameKey
 
LSTATUS utf8::RegSetValue (HKEY key, const std::string &value, DWORD type, const void *data, DWORD size)
 Wrapper for RegSetValueEx
 
LSTATUS utf8::RegSetValue (HKEY key, const std::string &value, const std::string &data)
 Convenience Wrapper for RegSetValueEx for string data.
 
LSTATUS utf8::RegSetValue (HKEY key, const std::string &value, const std::vector< std::string > &data)
 Convenience Wrapper for RegSetValueEx for vector of string data.
 
LSTATUS utf8::RegQueryValue (HKEY key, const std::string &value, DWORD *type, void *data, DWORD *size)
 Wrapper for RegQueryValueEx
 
LSTATUS utf8::RegGetValue (HKEY key, const std::string &subkey, const std::string &value, DWORD flags, void *data, DWORD *size, DWORD *type)
 Wrapper for RegGetValue
 
LSTATUS utf8::RegGetValue (HKEY key, const std::string &subkey, const std::string &value, std::string &data, bool expand)
 Retrieves a string from a registry key value using the RegGetValue function.
 
LSTATUS utf8::RegGetValue (HKEY key, const std::string &subkey, const std::string &value, std::vector< std::string > &data)
 Retrieves a vector of strings from a registry key value using the RegGetValue function.
 
LSTATUS utf8::RegEnumKey (HKEY key, DWORD index, std::string &name, DWORD maxlen, FILETIME *last_write_time)
 Wrapper for RegEnumKeyEx
 
LSTATUS utf8::RegEnumKey (HKEY key, std::vector< std::string > &names)
 Enumerate all subkeys of a key.
 
LSTATUS utf8::RegEnumValue (HKEY key, DWORD index, std::string &value, DWORD maxlen, DWORD *type, void *data, DWORD *data_len)
 Wrapper for RegEnumValue
 
LSTATUS utf8::RegEnumValue (HKEY key, std::vector< std::string > &values)
 Enumerate all values of a key.
 

Detailed Description

Wrappers for Windows registry functions.

For all these functions wide character strings arguments are replaced with UTF-8 encoded C++ strings.

Function Documentation

◆ RegCreateKey()

LSTATUS utf8::RegCreateKey ( HKEY  key,
const std::string &  subkey,
HKEY &  result,
DWORD  options,
REGSAM  sam,
const SECURITY_ATTRIBUTES *  psa,
DWORD *  disp 
)

Convenience wrapper for RegCreateKeyEx

Parameters
keyhandle to an open registry key
subkeyname of a subkey that this function opens or creates
resultnewly created key handle
optionsoption flags
samaccess rights for the new key
psapointer to SECURITY_ATTRIBUTES structure (can be NULL)
disppointer to a flag showing if key was created (REG_CREATED_NEW_KEY) or opened (REG_OPENED_EXISTING_KEY). Can be NULL.

◆ RegDeleteKey()

LSTATUS utf8::RegDeleteKey ( HKEY  key,
const std::string &  subkey,
REGSAM  sam 
)

Wrapper for RegDeleteKeyEx or RegDeleteKey

Parameters
keyhandle to an open registry key
subkeyname of a subkey to delete
samaccess mask specifies the platform-specific view of the registry:
  • KEY_WOW64_32KEY - Delete from 32-bit view of the registry
  • KEY_WOW64_64KEY - Delete from 64-bit view of the registry

If sam is 0, this function invokes RegDeleteKey function, deleting the 32-bit key if the invoking application is 32-bit, or the 64-bit key if the invoking application is 64-bit. Otherwise it invokes the RegDeleteKeyEx function.

◆ RegDeleteTree()

LSTATUS utf8::RegDeleteTree ( HKEY  key,
const std::string &  subkey 
)

Wrapper for RegDeleteTree

Parameters
keyhandle to an open registry key
subkeyname of a subkey to delete

If subkey is empty, the key and all subkeys and values are deleted.

◆ RegDeleteValue()

LSTATUS utf8::RegDeleteValue ( HKEY  key,
const std::string &  value 
)

Wrapper for RegDeleteValue

Parameters
keyhandle to an opened registry key
valuename of the value to delete.

If value is the empty string, the function removes the default key value.

◆ RegEnumKey() [1/2]

LSTATUS utf8::RegEnumKey ( HKEY  key,
DWORD  index,
std::string &  name,
DWORD  maxlen,
FILETIME *  last_write_time 
)

Wrapper for RegEnumKeyEx

Parameters
keyhandle of an opened registry key
indexenumeration index. Set to 0 for first subkey.
namename of enumerated subkey
maxlenmaximum length (in characters) of subkey name
last_write_timepointer to variable that receives the last time the subkey was written.

If maxlen parameter is 0, the function uses RegQueryInfoKey function to determine the maximum length.

◆ RegEnumKey() [2/2]

LSTATUS utf8::RegEnumKey ( HKEY  key,
std::vector< std::string > &  names 
)

Enumerate all subkeys of a key.

Parameters
keyhandle of an opened registry key
namesvector of strings containing names of all enumerated subkeys
Returns
ERROR_SUCCESS or a non-zero error code

◆ RegEnumValue() [1/2]

LSTATUS utf8::RegEnumValue ( HKEY  key,
DWORD  index,
std::string &  value,
DWORD  maxlen,
DWORD *  type,
void *  data,
DWORD *  data_len 
)

Wrapper for RegEnumValue

Parameters
keyhandle of an opened registry key
indexenumeration index. Set to 0 for first subkey.
valuename of enumerated value
maxlenmaximum length (in characters) of value name
typepointer to type of data stored in the value
datapointer to data stored in that value
data_lenpointer to size of data buffer in bytes

If maxlen parameter is 0, the function uses RegQueryInfoKey function to determine the maximum length of value name.

data_len parameter can be NULL only if data parameter is also NULL.

◆ RegEnumValue() [2/2]

LSTATUS utf8::RegEnumValue ( HKEY  key,
std::vector< std::string > &  values 
)

Enumerate all values of a key.

Parameters
keyhandle of an opened registry key
valuesvector of strings containing the names of all enumerated values
Returns
ERROR_SUCCESS or a non-zero error code

◆ RegGetValue() [1/3]

LSTATUS utf8::RegGetValue ( HKEY  key,
const std::string &  subkey,
const std::string &  value,
DWORD  flags,
void *  data,
DWORD *  size,
DWORD *  type 
)

Wrapper for RegGetValue

Parameters
keyhandle to an open registry key
subkeypath of the subkey from which the function retrieves the value
valuename of the value to be retrieved. If empty, the function retrieves the type and data for the key's unnamed or default value
flagsthe flags that restrict the data type of value to be queried.
datapointer to data
sizepointer to size data size (in bytes)
typepointer to type of data

◆ RegGetValue() [2/3]

LSTATUS utf8::RegGetValue ( HKEY  key,
const std::string &  subkey,
const std::string &  value,
std::string &  data,
bool  expand 
)

Retrieves a string from a registry key value using the RegGetValue function.

Parameters
keyhandle to an open registry key
subkeypath of the subkey from which the function retrieves the value
valuename of the value to be retrieved. If empty, the function retrieves the type and data for the key's unnamed or default value
dataretrieved registry data
expandif false, the function does not expand the REG_EXPAND_SZ strings

◆ RegGetValue() [3/3]

LSTATUS utf8::RegGetValue ( HKEY  key,
const std::string &  subkey,
const std::string &  value,
std::vector< std::string > &  data 
)

Retrieves a vector of strings from a registry key value using the RegGetValue function.

Parameters
keyhandle to an open registry key
subkeypath of the subkey from which the function retrieves the value
valuename of the value to be retrieved. If empty, the function retrieves the type and data for the key's unnamed or default value
dataretrieved vector of strings

◆ RegOpenKey()

LSTATUS utf8::RegOpenKey ( HKEY  key,
const std::string &  subkey,
HKEY &  result,
REGSAM  sam,
bool  link 
)

Wrapper for RegOpenKeyEx

Parameters
keyhandle to an open registry key
subkeyname of a subkey that this function opens
resultopened key handle
samaccess rights for opened key
linkset to true if key is a symbolic link

◆ RegQueryValue()

LSTATUS utf8::RegQueryValue ( HKEY  key,
const std::string &  value,
DWORD *  type,
void *  data,
DWORD *  size 
)

Wrapper for RegQueryValueEx

Parameters
keyhandle to an open registry key
valuename of the value to be retrieved. If empty, the function retrieves the type and data for the key's unnamed or default value
typepointer to type of data
datapointer to data
sizepointer to size data size (in bytes)

◆ RegRenameKey()

LSTATUS utf8::RegRenameKey ( HKEY  key,
const std::string &  subkey,
const std::string &  new_name 
)

Wrapper for RegRenameKey

Parameters
keyhandle to an open registry key
subkeyname of a subkey to rename
new_namenew subkey name

◆ RegSetValue() [1/3]

LSTATUS utf8::RegSetValue ( HKEY  key,
const std::string &  value,
const std::string &  data 
)

Convenience Wrapper for RegSetValueEx for string data.

Parameters
keyhandle to an open registry key
valuename of the value to be set. If empty, the function sets the type and data for the key's unnamed or default value
datavalue to be set

Value type is set to REG_SZ and data is appended a terminating NULL character.

◆ RegSetValue() [2/3]

LSTATUS utf8::RegSetValue ( HKEY  key,
const std::string &  value,
const std::vector< std::string > &  data 
)

Convenience Wrapper for RegSetValueEx for vector of string data.

Parameters
keyhandle to an open registry key
valuename of the value to be set. If empty, the function sets the type and data for the key's unnamed or default value.
datavalue to be set

Value type is set to REG_MULTI_SZ and formatted accordingly, with two terminating NULL characters.

◆ RegSetValue() [3/3]

LSTATUS utf8::RegSetValue ( HKEY  key,
const std::string &  value,
DWORD  type,
const void *  data,
DWORD  size 
)

Wrapper for RegSetValueEx

Parameters
keyhandle to an open registry key
valuename of the value to be set. If empty, the function sets the type and data for the key's unnamed or default value
typethe type of data
datapointer to data
sizedata size (in bytes)