Call the RegDeleteKey or RegDeleteValue function to delete registry keys and values, respectively. The key must be closed before you can properly delete it.