CCRegistry Class Reference

Class used for various registry operations, under a single pre-defined registry key. More...

#include <CCRegistry.h>

List of all members.

Public Types

enum  RegistryOperation
 

Possible registry error types.


Static Public Member Functions

static std::tstring GetString (HKEY hKey, LPCTSTR pPath, LPCTSTR pName, bool *pSuccess=NULL, DWORD dwExtraFlags=0)
 Retrieves a string registry value from anywhere in the registry.
static bool SetString (HKEY hKey, LPCTSTR pPath, LPCTSTR pName, LPCTSTR pValue)
 Sets a string value anywhere in the registry.
static bool GetBinary (HKEY hKey, LPCTSTR pPath, LPCTSTR pName, unsigned char *&pBuffer, int &nBytes)
 Retrieves a binary registry value from anywhere in the registry.
static bool SetBinary (HKEY hKey, LPCTSTR pPath, LPCTSTR pName, unsigned char *pBuffer, int nBytes)
 Sets a binary value anywhere in the registry.
static DWORD GetNumber (HKEY hKey, LPCTSTR pPath, LPCTSTR pName, bool *pSuccess=NULL)
 Retrieves a numeric value from the registry.
static bool SetNumber (HKEY hKey, LPCTSTR pPath, LPCTSTR pName, DWORD dwValue)
 Sets a numeric in the registry.
static bool TestWrite (HKEY hKey, LPCTSTR pPath)
 Tests if writing a value in the registry is allowed.
static RegistryOperation GetLastErrorOperation ()
 Returns the last registry error type.
static DWORD GetLastError ()
 Returns the last system error code for the registry operation.

Static Protected Attributes

static enum RegistryOperation eLastErrorOp = None
 Last error type.
static DWORD dwLastError = 0
 Last error code.

Detailed Description

Class used for various registry operations, under a single pre-defined registry key.

CCRegistry supports all kinds of registry operations, including basic ones like getting and setting of values (both string and numeric), and specific ones like retrieving C-Center plugin DLL paths. Additionally, it has a different registry base path depending on the product and debug mode (Cogniview vs. CogniviewD vs. CatIndex).

It should have been a namespace and not a class as it's a fully static class, has no members and all its functions are static.

Definition at line 47 of file CCRegistry.h.


Member Function Documentation

bool CCRegistry::GetBinary ( HKEY  hFromKey,
LPCTSTR  pPath,
LPCTSTR  pName,
unsigned char *&  pBuffer,
int &  nBytes 
) [static]

Retrieves a binary registry value from anywhere in the registry.

Parameters:
hKey the registry key to look in (can be any valid HKEY value)
pPath path to the string, inside the key
pName the string name
pBuffer[out] reference to a variable that receives the pointer to a new byte array containing the binary data
nBytes[out] number of bytes that were allocated and populated in pBuffer
Returns:
true if successful (in which case pBuffer should be delete []'ed), false otherwise

Definition at line 258 of file CCRegistry.cpp.

References dwLastError, and eLastErrorOp.

static DWORD CCRegistry::GetLastError (  )  [inline, static]

Returns the last system error code for the registry operation.

Returns:
The last error code

Definition at line 94 of file CCRegistry.h.

References dwLastError.

static RegistryOperation CCRegistry::GetLastErrorOperation (  )  [inline, static]

Returns the last registry error type.

Returns:
The last error type

Definition at line 89 of file CCRegistry.h.

References eLastErrorOp.

DWORD CCRegistry::GetNumber ( HKEY  hFromKey,
LPCTSTR  pPath,
LPCTSTR  pName,
bool *  pSuccess = NULL 
) [static]

Retrieves a numeric value from the registry.

Parameters:
hFromKey the registry key to look in (can be any valid HKEY value)
pPath path to the number, under the base key
pName name of the number
[out] pSuccess If not NULL, will contain a success flag.
Returns:
The numeric value from the registry. Note that 0 will also be returned if the value is empty; in order to differenciate between those cases, use the pSuccess parameter.

Definition at line 198 of file CCRegistry.cpp.

References dwLastError, and eLastErrorOp.

std::tstring CCRegistry::GetString ( HKEY  hFromKey,
LPCTSTR  pPath,
LPCTSTR  pName,
bool *  pSuccess = NULL,
DWORD  dwExtraFlags = 0 
) [static]

Retrieves a string registry value from anywhere in the registry.

Parameters:
hFromKey the registry key to look in (can be any valid HKEY value)
pPath path to the string, inside the key
pName the string name
[out] pSuccess If not NULL, will contain a success flag.
Returns:
The retrieved string, empty if failed. Note that an empty string will also be returned if the value is empty; in order to differenciate between those cases, use the pSuccess parameter.

Definition at line 46 of file CCRegistry.cpp.

References dwLastError, eLastErrorOp, and tstring.

bool CCRegistry::SetBinary ( HKEY  hKey,
LPCTSTR  pPath,
LPCTSTR  pName,
unsigned char *  pBuffer,
int  nBytes 
) [static]

Sets a binary value anywhere in the registry.

Parameters:
hKey the registry key to look in (can be any valid HKEY value)
pPath path to the string, inside the key
pName the string name
pBuffer pointer to the byte array to store
nBytes number of bytes in pBuffer to store
Returns:
true if successful, false otherwise

Definition at line 322 of file CCRegistry.cpp.

References dwLastError, and eLastErrorOp.

bool CCRegistry::SetNumber ( HKEY  hFromKey,
LPCTSTR  pPath,
LPCTSTR  pName,
DWORD  dwValue 
) [static]

Sets a numeric in the registry.

Parameters:
hFromKey the registry key to look in (can be any valid HKEY value)
pPath path to the number, under the base key
pName name of the number
dwValue number value
Returns:
false on error, true on success

Definition at line 167 of file CCRegistry.cpp.

References dwLastError, and eLastErrorOp.

bool CCRegistry::SetString ( HKEY  hKey,
LPCTSTR  pPath,
LPCTSTR  pName,
LPCTSTR  pValue 
) [static]

Sets a string value anywhere in the registry.

Parameters:
hKey the registry key to look in (can be any valid HKEY value)
pPath path to the string, inside the key
pName the string name
pValue the string to set
Returns:
true if successfully set, false otherwise

Definition at line 117 of file CCRegistry.cpp.

References dwLastError, and eLastErrorOp.

bool CCRegistry::TestWrite ( HKEY  hKey,
LPCTSTR  pPath 
) [static]

Tests if writing a value in the registry is allowed.

Parameters:
hKey the registry key to look in (can be any valid HKEY value)
pPath path to the string, inside the key
Returns:
true if successfully set, false otherwise

Definition at line 145 of file CCRegistry.cpp.

References dwLastError, and eLastErrorOp.


Member Data Documentation

Last error type.

Last error's operation.

Definition at line 98 of file CCRegistry.h.

Referenced by GetBinary(), GetLastErrorOperation(), GetNumber(), GetString(), SetBinary(), SetNumber(), SetString(), and TestWrite().


The documentation for this class was generated from the following files:

Generated on Mon Jun 18 12:40:43 2012 for CC PDF Converter by doxygen 1.6.1