_RegDeleteKey

DWORD _RegDeleteKey(HKEY hKey, LPSTR lpszSubKey)
 

Deletes the given registry key including its subkeys from the registry database.

hKey
Handle of a previously opened key.
lpszSubKey
Address of a null-terminated string specifying the subkey to delete.

This service also marks all other open references to the key being deleted as deleted, so that all accesses through these other open references will fail with an ERROR_KEY_DELETED error. But a virtual device could create a new key with the same name, even before these open references are closed, without any conflict.