# RegWriteBinary

int RegWriteBinary (unsigned int rootKey, const char subkeyName[], const char valueName[], const unsigned char dataBuffer[], int bytesToCopy);

## Purpose

This function writes a buffer of data into the Registry in binary format. You must specify a Root Key, a Subkey of that Root Key, and the actual Value of that Subkey to which you want to write the data. Any data that exists already at the specified Key value will be overwritten.

Example:

unsigned char buffer[100];
// Writes the first 10 bytes of buffer to MyBinaryValue
RegWriteBinary (REGKEY_HKLM, "Software\\MySubKey",
"MyBinaryValue", buffer, 10);

## Parameters

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), to which you want to write value data. See the Windows Registry functions Class help for more information on Subkeys.
valueName | const char [] | The name of the value to which you want to write data. If the value name does not exist this function will create it. See the Windows Registry functions Class help for more information on Key Values.
dataBuffer | const unsigned char [] | The buffer whose contents you wish to write to the specified Value of the specified Subkey. This function does not make any assumtions about the contents of this buffer, and data is written as–is to the Registry.
bytesToCopy | integer | The number of bytes you wish to copy from the input Buffer into the Registry. This value must not be any larger than the size of the input Buffer.

## Return Value

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.