python winreg 示例,pythonwinreg,下面是关于_winreg
python winreg 示例,pythonwinreg,下面是关于_winreg
下面是关于_winreg模块的示例
import Tkinter as _TKimport tkMessageBox as _MBimport winreg as _wiimport install as _in################################################################################class _Virtual: '_Virtual(key) -> _Virtual' def __init__(self, key): 'Initialize the _Virtual object.' self.__delitem__ = self.__dict__.__delitem__ self.__getitem__ = self.__dict__.__getitem__ self.__setitem__ = self.__dict__.__setitem__ self.__key = key for value in key.values: if value.isupper(): self[value] = _unpack(key.values[value]) elif value.isdigit(): self[int(value)] = _unpack(key.values[value]) def __del__(self): 'Update the registry.' del self.__key.values for value in self: self.__key.values[str(value)] = self.__pack(self[value]) def __iter__(self): 'Iterate over the values in self.' return iter(filter(lambda value: isinstance(value, int) or isinstance(value, str) and value.isupper(), self.__dict__.keys())) __pack = staticmethod(_in.solve)################################################################################def _unpack(value): 'Correctly unpack the value.' if isinstance(value, _wi.REG_SZ): return str(value.value) elif isinstance(value, _wi.REG_DWORD): return int(value.value) elif isinstance(value, _wi.REG_MULTI_SZ): return map(str, value.value) raise NotImplementedError, 'Cannot solve for %s' % type(value)def _export(key, ignore): 'Export all subkeys in key to globals.' try: GLOBAL = globals() root = _wi.Key(_wi.HKEY.CURRENT_USER, key) for key in root.keys: GLOBAL[key] = obj = _Virtual(_wi.Key(root, key, _wi.KEY.ALL_ACCESS)) attr = getattr(_in, key) delattr(_in, key) if key not in ignore: for key in obj: assert type(obj[key]) == type(attr[key]) del attr[key] assert not attr assert not sum(map(lambda name: name.isupper(), dir(_in))) except: _TK.Tk().withdraw() _MB.showerror('Error', 'Please install this program first.') raise SystemExit, 1################################################################################_export('Software\\Atlantis Zero\\Kaos Rain\\Version 3', ['HST'])
这个模块可以自动加载或者改变Windows注册表的设置
相关内容
- python连接sql server数据库,pythonsql,首先,到http://p
- Basic synchronization decorator,,下面代码是对python
- 初学python,,初学python[Pyt
- python实现多线程下载,python实现多线程,python实现多线程
- 金山快盘自动签到程序,金山签到程序,自动签到领取积
- python多线程Ping网段,python多线程ping,通过修改本站一个
- python用多个分隔符拆分字符串,python分隔符,如下代码,
- python计算指定两点经纬度之间的距离,python经纬度,下面
- python urllib quote或者quote_plus 抛出keyError的解决方案,u
- python2.7将doc文件转换成文本文件(windows),python2.7do
评论关闭