Writing and Deleting Registry Data
An application can use the RegSetValueEx function to associate a value and its data with a key. For a list of the value types supported by RegSetValueEx, see Registry Value Types.
To delete a value from a key, an application can use the RegDeleteValue function. To delete a key, it can use the RegDeleteKey function. A deleted key is not removed until the last handle to it has been closed. Subkeys and values cannot be created under a deleted key.
It is not possible to lock a registry key during a write operation to synchronize access to the data. However, you can control access to a registry key using security attributes. For more information, see Registry Key Security and Access Rights.
More than one registry operation can be performed within a single transaction. To associate a registry key with a transaction, an application can use the RegCreateKeyTransacted or RegOpenKeyTransacted function. For more information about transactions, see Kernel Transaction Manager.