Loop through values or registry key.. _winreg Python

前端 未结 5 610
清歌不尽
清歌不尽 2021-01-17 21:40

How would I loop through all the values of a Windows Registry Key using the Python module _winreg. I have code that will do what I want, but it is

5条回答
  •  Happy的楠姐
    2021-01-17 22:04

    for python 3

    import winreg
    hKey = winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, "Local Settings\\Software\\Microsoft\\Windows\\Shell\\MuiCache")
    
    
    try:
        count = 0
        while 1:
            name, value, type = winreg.EnumValue(hKey, count)
            print (name),
            count = count + 1
    except WindowsError as err:
        print(err)
        pass
    

提交回复
热议问题