Python winreg items are looped through a subkey
Python winreg
I was able to retrieve 5 sub keys from the code under my Windows 7 Machine registry hive "HKEY_LOCAL_MACHINE".
from _winreg import *try: i = 0 while True: subkey = EnumKey(HKEY_LOCAL_MACHINE, i) print subkey i += 1except WindowsError: pass
My question is, how do I base these buttons again? I want to finally list all the keys in software \ \ MICROSOFT \ \ Windows nt \ currentversion \ \ networklist \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ In the answer priority I ran my machine on the captcha, although it didn't make a mistake when it didn't produce the result.
from _winreg import *aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\Unmanaged")for i in range(1024): try: keyname = EnumKey(aKey, i) asubkey = OpenKey(aKey, keyname) val = QueryValueEx(asubkey, "Description") print val except WindowsError: break
À registry Editor or register query shows 6 values in that folder, but I can't get a Python script for these six.
This address: codego.net/8981951/
--------------------------------------------------------------------------------------------------------------- ----------
1. Do you have a job like this?
import _winregdef subkeys(key): i = 0 while True: try: subkey = _winreg.EnumKey(key, i) yield subkey i+=1 except WindowsError: breakdef traverse_registry_tree(key=_winreg.HKEY_LOCAL_MACHINE, tabs=0): for k in subkeys(key): print ‘\t‘*tabs + str(k) traverse_registry_tree(k, tabs+1)
2. I do not have a registry key search, but the following code will list all subkeys in HKEY_LOCAL_MACHINE \ \ Software. I think that if you change the value of the Keyval string into your directory, it will work. The try ... except
whole is such that EnumKey will fail. I didn't do it as a loop I don't know how to akey the right length.
keyVal = r"Software"aKey = OpenKey(HKEY_LOCAL_MACHINE, keyVal, 0, KEY_ALL_ACCESS)try: i = 0 while True: asubkey = EnumKey(aKey, i) print(asubkey) i += 1except WindowsError: pass
This article title: Python's winreg items are looped through a subkey
This address: codego.net/8981951/
The winreg entry of a python is looped through a sub-key