Registry::GetValue
GetValue
Description
Retrieves the data for a specified value name associated with a subkey.
Retrieves the data for a specified value name associated with a subkey.
Retrieves the data for a specified value name associated with a subkey.
Syntax
BOOL GetValue( LPCSTR lpSubKey, LPCSTR lpValueName, DWORD & dwValue )
BOOL GetValue( LPCSTR lpSubKey, LPCSTR lpValueName, string & strValue )
BOOL GetValue( LPCSTR lpSubKey, LPCSTR lpValueName, LPBYTE lpData, LPDWORD lpcbData, LPDWORD lpType = NULL )
Parameters
- lpSubKey
- [input]Pointer to a null-terminated string containing the name of the subkey to open.
- lpValueName
- [input]Pointer to a string containing the name of the value to query.
- If this parameter is NULL or an empty string, "", the function retrieves
- the type and data for the key's unnamed or default value, if any.
- dwValue
- [output]A DWORD that receives the value of the data.
- lpSubKey
- [input]Pointer to a null-terminated string containing the name of the subkey to open.
- lpValueName
- [input]Pointer to a string containing the name of the value to query.
- If this parameter is NULL or an empty string, "", the function retrieves
- the type and data for the key's unnamed or default value, if any.
- strValue
- [output]A string that receives the value of the data.
- lpSubKey
- [input]Pointer to a null-terminated string containing the name of the subkey to open.
- lpValueName
- [input]Pointer to a string containing the name of the value to query.
- If this parameter is NULL or an empty string, "", the function retrieves
- the type and data for the key's unnamed or default value, if any.
- lpData
- [output]Pointer to a buffer that receives the value of the data. This parameter can be NULL if the data is not required.
- lpcbData
- [output]Pointer to a variable that specifies the size, in bytes, of the buffer pointed to by the lpData parameter.
- When the function returns, this variable contains the size of the data copied to lpData.
- lpType
- [output]Pointer to a variable that receives the type of data associated with the specified value, The lpType parameter can be NULL if the type is not required.
Return
TRUE if key value pair is in registry, FALSE if not
TRUE if key value pair is in registry, FALSE if not
Examples
EX1
void Registry_GetValue_ex1()
{
DWORD dwCntrl;
Registry myRegAccess(HKEY_CLASSES_ROOT);
if( myRegAccess.HasKey("a\\b\\c") )
myRegAccess.GetValue("a\\b\\c", "Control", dwCntrl);
}
EX2
void Registry_GetValue_ex2()
{
string strLabel;
Registry myRegAccess(HKEY_CLASSES_ROOT);
if( myRegAccess.HasKey("a\\b\\c") )
myRegAccess.GetValue("a\\b\\c", "Label", strLabel);
}
EX3
#define MY_BUFSIZE 8
void Registry_GetValue_ex3()
{
byte szValue[MY_BUFSIZE];
DWORD dwBufLen = MY_BUFSIZE;
string strSubKey = "Classes\\CLSID\\{B0F21977-8AAB-4632-A73D-528B909C5663}\\InProcServer32";
Registry myRegAccess(HKEY_CLASSES_ROOT);
if( myRegAccess.HasKey("a\\b\\c") )
myRegAccess.GetValue("a\\b\\c", strSubKey, (LPBYTE)szValue, &dwBufLen);
}
Remark
See Also
header to Include
origin.h
|