Python如何获取注册表中的文件夹名称

标签 python windows registry directory

我想要获取注册表中某个路径的文件夹名称,而不是键值!

我已经可以读取键值,那么如何读取文件夹值?

我想要它,因为我需要版本号。 libreOffice的,它只存储在文件夹名称中。

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")

最佳答案

使用EnumKey迭代“文件夹”(在注册表中称为“键”)

parentKey = winreg.OpenKey(root, dir)
i = 0
while True:
   try:
       key = winreg.EnumKey(parent, i)
       print key
       i += 1
   except WindowsError: 
       break

关于Python如何获取注册表中的文件夹名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12406150/

相关文章:

c# - 如何在 python 3 中解码由 C# Convert.ToBase64String 编码的字符串

python - 从 Windows 访问 ubuntu 文件(安装在 virtualbox 中)

c# - 如何通过 C# 使用 WMI 从在 64 位机器 (WOW) 上以 32 位模式运行的应用程序访问 64 位注册表配置单元信息

windows - 如何创建名称中带有正斜杠的注册表项

windows - 告诉 Puppet 仅在注册表项不存在时运行安装

Python:如何计算两个IP地址和端口之间接收和发送的数据

python : setting colour limits for basemap's pcolormesh

java - 我如何获得用户音乐目录?

c - 在 Windows 中跨重启访问相同的资源

windows - 使用任务计划程序通过自动屏幕捕获获取空白(黑色)屏幕截图