2

i want to get the folder name of a path in the registry, not the key value!

I can already read a key value, so how do i read a folder value?

I want it because i need the version nr. of libreOffice,its only stored in the folder name.

def getRegistryKeyValue (self, root, dir, key):
       currentKey = winreg.OpenKey(root, dir)
       currentVersion, valuetype = winreg.QueryValueEx(currentKey, key)

key = self.getRegistryKeyFolder(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\LibreOffice")

1 Answer 1

3

Use EnumKey to iterate over "folders" (called "keys" in the registry)

parentKey = winreg.OpenKey(root, dir)
i = 0
while True:
   try:
       key = winreg.EnumKey(parent, i)
       print key
       i += 1
   except WindowsError: 
       break
Sign up to request clarification or add additional context in comments.

1 Comment

I linked to the docs... but I've added sample now. Hope it helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.