又一个注册表包装器
YARW的Python项目详细描述
yarw:又一个注册表包装器
这个配方提供了“registry”,一个windows注册表包装类 使使用Windows注册表更容易。这个班和一个 名为“registry key”的内部类,用于包装Windows注册表项 并提供访问和操作密钥信息的方法。这个 类为 _ WinReg公司。
示例
key=Registry.open('HKEY_LOCAL_MACHINE',"SOFTWARE\\Python")# Prints the RegistryKey instanceprintkey# Prints the key name and the wrapped up PyHKEY instanceprintkey.getkeyname(),key.getkey()corekey=key.openkey(1)idx=0# Print the install path for Python 2.4 if installed.whileTrue:try:keyname=corekey.enumkey(idx)idx+=1ifkeyname=='2.4':keyVersion=corekey.openkey(idx)printkeyVersion,keyVersion.getkeyname()keyPath=keyVersion.openkey(2)printkeyPath,keyPath.getkeyname()print'Install path is %s'%keyPath.getvalue()keyPath.close()keyVersion.close()breakexceptRegistryError:breakcorekey.close()key.close()