Python获取注册表中的信息

Python2

此文为获取Maya2018在注册表中的路径

import _winreg

string = r'SOFTWARE\Autodesk\Maya\2018\Setup\InstallPath'
handle = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, string)
location, _type = _winreg.QueryValueEx(handle, "MAYA_INSTALL_LOCATION")
print(location)

Python3

import winreg

string = r'SOFTWARE\Autodesk\Maya\2018\Setup\InstallPath'
handle = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, string, 0, (winreg.KEY_WOW64_64KEY + winreg.KEY_READ))
location, _type = winreg.QueryValueEx(handle, "MAYA_INSTALL_LOCATION")
print(location)

你可能感兴趣的:(知识点)