4.2 Writing a Registry Key and Value
The operations in writing a registry key and value are as follows:
The client obtains a handle to one of the root keys, for example HKEY_LOCAL_MACHINE, by using the OpenLocalMachine method.
The client uses the handle to the root key with the BaseRegOpenKey method to open a subkey. The BaseRegOpenKey method returns a handle to the subkey.
The client uses the handle to the subkey with the BaseRegCreateKey method to create new subkeys.
The client uses the handle to a subkey to write values under the subkey by using the BaseRegSetValue method. The client uses the value for client-specific operations.
After all required keys and values have been created and written, the client closes the open handles by using the BaseRegCloseKey method.
If there are multiple writes to the same registry key or value, the last one wins. No ordering relationships can be specified.