Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

OW32::CRegKey Class Reference

Wrapper for registry key access. More...

#include <RegKey.h>

List of all members.

Public Member Functions

 CRegKey ()
 Default constructor for a closed key.
 CRegKey (HKEY hKey)
 Construct from an existing registry key.
void Close ()
 Close any open registry key.
LONG Open (HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired=KEY_READ)
 Open a sub-key.
template<class T>
LONG QueryValue (std::basic_string< T > &strValue, LPCTSTR lpszValueName=NULL)
 Fetch a string value. This copes with REG_SZ, REG_EXPAND_SZ or REG_MULTI_SZ. For REG_MULTI_SZ the final null terminator of the string pairs is not present (but c_str() will give the correct data as it appends a NULL...).
template<class T>
LONG EnumKey (DWORD index, std::basic_string< T > &name, FILETIME *pftime=NULL)
 Enumerate registry keys.
template<class T>
LONG EnumValue (DWORD index, std::basic_string< T > &name, DWORD *pType=NULL, BYTE **ppData=NULL, DWORD *pLenData=NULL)
 Enumerate values under a given registry key.
LONG QueryValue (BYTE *Buf, DWORD *BufSize, LPCTSTR lpszValueName=NULL)
 Fetch a binary value.
template<class T>
LONG QueryValue (T *buf, int nBuf, LPCTSTR lpszValueName=NULL)
 Fetch a string value.
LONG QueryValue (DWORD &dwValue, LPCWSTR lpszValueName=NULL)
 Fetch a DWORD value.
LONG QueryValue (DWORD &dwValue, LPCSTR lpszValueName=NULL)
 Fetch a DWORD value.
LONG Create (HKEY hKeyParent, LPCTSTR lpszKeyName, LPTSTR lpszClass=REG_NONE, DWORD dwOptions=REG_OPTION_NON_VOLATILE, REGSAM samDesired=KEY_ALL_ACCESS, LPSECURITY_ATTRIBUTES lpSecAttr=NULL, LPDWORD lpdwDisposition=NULL)
 Create a new key and attach it to this class.
LONG DeleteValue (LPCTSTR lpszValueName=NULL)
 Delete an existing value.
LONG DeleteKey (LPCTSTR lpSubKey=NULL)
 Delete a subkey of the current key.
LONG SetValue (LPCTSTR lpszValue, LPCTSTR lpszValueName=NULL)
 Set a string value under the given key.
LONG SetValue (const BYTE *pData, LONG bufSize, DWORD dwType=REG_BINARY, LPCTSTR lpszValueName=NULL)
 Set a binary value under the given key.
LONG SetValue (DWORD dwValue, LPCTSTR lpszValueName=NULL)
 Set a DWORD value under the given key.
LONG Flush ()
 Flush changes to the current key.
 operator HKEY ()
 HKEY extractor for use with API functions.

Static Public Member Functions

 IsStringType (DWORD dwType)
 return TRUE if the given type is one of REG_EXPAND_SZ, REG_MULTI_SZ or REG_SZ
 IsDWORDType (DWORD dwType)
 return TRUE if the given type is one of REG_DWORD, REG_DWORD_LITTLE_ENDIAN or REG_DWORD_BIG_ENDIAN.


Detailed Description

Wrapper for registry key access.


Member Function Documentation

LONG OW32::CRegKey::Create HKEY  hKeyParent,
LPCTSTR  lpszKeyName,
LPTSTR  lpszClass = REG_NONE,
DWORD  dwOptions = REG_OPTION_NON_VOLATILE,
REGSAM  samDesired = KEY_ALL_ACCESS,
LPSECURITY_ATTRIBUTES  lpSecAttr = NULL,
LPDWORD  lpdwDisposition = NULL
[inline]
 

Create a new key and attach it to this class.

Returns:
LONG value indicating success or failure
Parameters:
hKeyParent An existing key to create the new key under.
lpszKeyName The name of the new key.
lpszClass The class (object type) of the new key.
dwOptions miscellaneous options for the new key.
samDesired Access permissions for the new key.
lpSecAttr Security descriptor for the new key.
lpdwDisposition Output specifying if the key was created or simply opened.

LONG OW32::CRegKey::DeleteKey LPCTSTR  lpSubKey = NULL  )  [inline]
 

Delete a subkey of the current key.

Returns:
LONG value indicating success or failure
Parameters:
lpSubKey the name of the key to delete

LONG OW32::CRegKey::DeleteValue LPCTSTR  lpszValueName = NULL  )  [inline]
 

Delete an existing value.

Returns:
LONG value indicating success or failure
Parameters:
lpszValueName the name of the value to delete, or the default value if not specified.

template<class T>
LONG OW32::CRegKey::EnumKey DWORD  index,
std::basic_string< T > &  name,
FILETIME *  pftime = NULL
[inline]
 

Enumerate registry keys.

Returns:
LONG value indicating success or failure
Parameters:
index The current fetch index.
name Output - the name of the key
pftime The time the key was last written to.

template<class T>
LONG OW32::CRegKey::EnumValue DWORD  index,
std::basic_string< T > &  name,
DWORD *  pType = NULL,
BYTE **  ppData = NULL,
DWORD *  pLenData = NULL
[inline]
 

Enumerate values under a given registry key.

Parameters:
index The current fetch index.
strValue Output - the value's name
pType Output - the type of the returned value
ppData Output - a buffer allocated with new[] containing the data
pLenData Output - the length of the returned buffer
Returns:
LONG value indicating success or failure

LONG OW32::CRegKey::Flush  )  [inline]
 

Flush changes to the current key.

Returns:
LONG value indicating success or failure

LONG OW32::CRegKey::Open HKEY  hKeyParent,
LPCTSTR  lpszKeyName,
REGSAM  samDesired = KEY_READ
[inline]
 

Open a sub-key.

Returns:
A LONG indicating success or failure.
Parameters:
hKeyParent Handle of the key that the sub-key lives under.
lpszKeyName The name of the registry key to open.
samDesired The access desired to the key, defaults to KEY_READ.

LONG OW32::CRegKey::QueryValue DWORD &  dwValue,
LPCSTR  lpszValueName = NULL
[inline]
 

Fetch a DWORD value.

Returns:
LONG value indicating success or failure
Parameters:
buf dwValue the output value
lpszValueName the name of the value to fetch, or the default value if not specified.

LONG OW32::CRegKey::QueryValue DWORD &  dwValue,
LPCWSTR  lpszValueName = NULL
[inline]
 

Fetch a DWORD value.

Returns:
LONG value indicating success or failure
Parameters:
buf dwValue the output value
lpszValueName the name of the value to fetch, or the default value if not specified.

template<class T>
LONG OW32::CRegKey::QueryValue T *  buf,
int  nBuf,
LPCTSTR  lpszValueName = NULL
[inline]
 

Fetch a string value.

Returns:
LONG value indicating success or failure
Parameters:
buf The output buffer
nBuf The size of the output buffer.
lpszValueName the name of the value to fetch, or the default value if not specified.

LONG OW32::CRegKey::QueryValue BYTE *  Buf,
DWORD *  BufSize,
LPCTSTR  lpszValueName = NULL
[inline]
 

Fetch a binary value.

Returns:
LONG value indicating success or failure
Parameters:
Buf The output buffer
BufSize On input, the size of the output buffer. On output, the amount of the buffer that has been used.
lpszValueName the name of the value to fetch, or the default value if not specified.

template<class T>
LONG OW32::CRegKey::QueryValue std::basic_string< T > &  strValue,
LPCTSTR  lpszValueName = NULL
[inline]
 

Fetch a string value. This copes with REG_SZ, REG_EXPAND_SZ or REG_MULTI_SZ. For REG_MULTI_SZ the final null terminator of the string pairs is not present (but c_str() will give the correct data as it appends a NULL...).

Parameters:
strValue Output - the returned string
lpszValueName The name of the value to return, this is the default value if not specified.

LONG OW32::CRegKey::SetValue DWORD  dwValue,
LPCTSTR  lpszValueName = NULL
[inline]
 

Set a DWORD value under the given key.

Returns:
LONG value indicating success or failure
Parameters:
pData The binary data to set.
bufSize The length of the binary data.
lpszValueName the name of the value to delete, or the default value if not specified.

LONG OW32::CRegKey::SetValue const BYTE *  pData,
LONG  bufSize,
DWORD  dwType = REG_BINARY,
LPCTSTR  lpszValueName = NULL
[inline]
 

Set a binary value under the given key.

Returns:
LONG value indicating success or failure
Parameters:
pData The binary data to set.
bufSize The length of the binary data.
dwType The type, defaults to binary
lpszValueName the name of the value to delete, or the default value if not specified.

LONG OW32::CRegKey::SetValue LPCTSTR  lpszValue,
LPCTSTR  lpszValueName = NULL
[inline]
 

Set a string value under the given key.

Returns:
LONG value indicating success or failure
Parameters:
lpszValue The value to set.
lpszValueName the name of the value to delete, or the default value if not specified.


The documentation for this class was generated from the following file:
Generated on Sun Jun 5 01:29:26 2005 for OW32 by  doxygen 1.3.9.1