winreg
(Windows Registry API) provides functions to expose the Windows Registry API to Python. We use this module to expose a low-level interface to the registry.
The method DeleteKeyEx
removes any specified key. The method takes key
, sub_key
, access
, and reserved
as parameters.
Using this method removes all keys and their values. Otherwise, the method raises an OSError exception
.
winreg.DeleteKeyEx(key, sub_key, access=KEY_WOW64_64KEY, reserved=0)
key
: Any open HKEY_*
constant or one of the predefined HKEY_*
constants can be given as a parameter to the method.
sub_key
: The subkey of any given key. It is a string value. This parameter cannot have a value of None
.
reserved
: A reserved integer that contains the value 0
.
access
: An integer value that defines any security access for the desired key. We refer to this as an access mask with a default value of KEY_WOW64_64KEY
. However, it can contain other values as well.
Using this method, a user cannot delete a specified key if that key itself has subkeys.
Free Resources