int RegReadBinary (unsigned int rootKey, const char subkeyName[], const char valueName[], unsigned char dataBuffer[], unsigned int bufferSize, unsigned int *realDataSize);
This function reads raw binary data from the specified Key Value in the Windows Registry. You must specify a Root Key, a Subkey of that Root Key, and the actual Value of that Subkey which you want to read.
If you do not know the size of the data in the Registry, you may pass NULL for the dataBuffer parameter. The function will determine the size of the data and return it through realDataSize. You may then use this value to allocate appropriate space for the data, and call the function again.
Example:
unsigned char *buffer = NULL;
unsigned int size;
RegReadBinary (REGKEY_HKLM, "Software\\MySubKey",
"MyBinaryValue", NULL, 0, &size);
buffer = (unsigned char*) malloc(size * sizeof(unsigned char));
if (buffer != NULL) {
RegReadBinary (REGKEY_HKLM, "Software\\MySubKey",
"MyBinaryValue", buffer, size, &size);
// use the data in buffer …
free (buffer);
}
Input | ||
Name | Type | Description |
rootKey | unsigned integer | The Root Key under which you wish to access a Subkey and its value. See the Windows Registry functions Class help for more information on Root Keys. |
subkeyName | const char [] | The name of the Subkey, relative to the Root Key, from which you wish to read value data. See the Windows Registry functions Class help for more information on Subkeys. |
valueName | const char [] | The name of the Value from which you want to read data. See the Windows Registry functions Class help for more information on Key Values. |
bufferSize | unsigned integer | The size of the buffer passed to dataBuffer. This parameter is ignored when you pass NULL in place of an actual buffer. |
Output | ||
Name | Type | Description |
dataBuffer | unsigned char [] | Returns the binary contents of the specified Value of the specified Subkey. This buffer must be large enough to receive all of the binary data. If you are unsure of the size of the data, you may pass NULL. The realDataSize parameter will return the actual size of the data in the Registry. |
realDataSize | unsigned integer * | Returns the actual size of the data associated with the specified registry Key. You may pass NULL for the dataBuffer parameter and use this value to allocate adequate memory before calling this function again. |
Name | Type | Description |
status | integer | The status code that the function returns. 0 indicates success. A negative value indicates an error. This function may return a Programmer's Toolbox or UI Library error code. Call GetGeneralErrorString to obtain a text description of the error. |