I\'m able to successfully retrieve the 5 sub-keys from my windows 7 machine registry hive \"HKEY_LOCAL_MACHINE\" with the code below.
from _winreg import *
For iterating through keys of Windows registry, you would need EnumKey()
from _winreg
module. Given below is the definition for EnumKey()
:-
def EnumKey(key, index):
- Enumerates subkeys of an open registry key.
- key is an already open key, or any one of the predefined HKEY_* constants.
- index is an integer that identifies the index of the key to retrieve.
Note that this method, takes index as an argument, and will provide you the key only for the given index. Therefore, in order to get all the keys, you need to increment the index by one and continue until you encounter WindowsError
.
Refer to this post for a detailed understanding on the same. The Github link for the code can be found in the post.