title: Getting all windows registry values along with their paths using PYTHON
body: <p>what id did is........this code loops itself among keys and subkeys and checks if the key has any values if present prints values. For this code the pointer or whatever moves from HKEY_CURRENT_CONFIG to System and to CurrentControlSet and CurrentControlSet has one value(i manually created it) but the error iam getting as</p>
  
  <p>Traceback (most recent call last): System File "C:/Users/siva kumar/PycharmProjects/delete this/3.py", line 34, in System\CurrentControlSet traverse_registry_tree(winreg.HKEY_CURRENT_CONFIG, keypath) r"System\CurrentControlSet" File "C:/Users/siva kumar/PycharmProjects/delete this/3.py", line 21, in traverse_registry_tree x = winreg.OpenKey(winreg.HKEY_CURRENT_CONFIG, y, 0, winreg.KEY_READ | winreg.KEY_WOW64_32KEY) #%('r',subkeypath) FileNotFoundError: [WinError 2] The system cannot find the file specified</p>
  
  <pre><code>import winreg
  
  def subkeys(key):
      i = 0
      while True:
          try:
              subkey = winreg.EnumKey(key, i)
              yield subkey
              i+=1
          except WindowsError as e:
              break
  
  def traverse_registry_tree(hkey, keypath, tabs=1):
      key = winreg.OpenKey(hkey, keypath, 0, winreg.KEY_READ)
      for subkeyname in subkeys(key):
  
          subkeypath = "%s\\%s" % (keypath, subkeyname)
          print(subkeypath)
          y='%s''"%s"' %('r',subkeypath)
          print(y)
          x = winreg.OpenKey(winreg.HKEY_CURRENT_CONFIG, y, 0, winreg.KEY_READ)
  
          z=winreg.QueryInfoKey(x)[1]
          print(z)
  
          if z!=0:
              for i in range(0, z):
                  print(winreg.EnumValue(key, i))
  
      traverse_registry_tree(hkey, subkeypath, tabs+1)
  
  keypath = r"System"
  print("System")
  traverse_registry_tree(winreg.HKEY_CURRENT_CONFIG, keypath)
  </code></pre>