import _winreg as winreg def regkey_value(path, name="", start_key = None): if isinstance(path, str): path = path.split("\\") if start_key is None: start_key = getattr(winreg, path[0]) return regkey_value(path[1:], name, start_key) else: subkey = path.pop(0) with winreg.OpenKey(start_key, subkey) as handle: assert handle if path: return regkey_value(path, name, handle) else: desc, i = None, 0 while not desc or desc[0] != name: desc = winreg.EnumValue(handle, i) i += 1 return desc[1] # example usage bios_vendor = regkey_value(r"HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "BIOSVendor")
출처 : https://code.activestate.com/recipes/578689-get-a-value-un-windows-registry/
분석 필요함
댓글 없음:
댓글 쓰기