与Windows注册表相关
lib-registr的Python项目详细描述
库注册表
一些方便的函数来访问windows注册表-待扩展。
支持Python2.7-Python3.7以及其他方言。
100% code coverage,在Windows and Wine下测试
安装和升级
源代码:
# normal install python setup.py install # test without installing python setup.py test
VIA PIP最新版本:
# latest Release from pypi
pip install lib_registry
VIA PIP最新开发版本:
# upgrade all dependencies regardless of version number (PREFERRED) pip install --upgrade https://github.com/bitranox/lib_registry/archive/master.zip --upgrade-strategy eager # normal install pip install --upgrade https://github.com/bitranox/lib_registry/archive/master.zip # test without installing pip install --upgrade https://github.com/bitranox/lib_registry/archive/master.zip --install-option test
通过Requirements.txt:
# Insert following line in Your requirements.txt: # for the latest Release: lib_registry # for the latest Development Version : https://github.com/bitranox/lib_registry/archive/master.zip # to install and upgrade all modules mentioned in requirements.txt: pip install --upgrade -r /<path>/requirements.txt
通过Python:
python -m pip install --upgrade lib_registry
基本用法
>>>fromlib_registryimport*>>># Read a Value from the Registry>>>key='HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\S-1-5-20'>>>get_value(key_name=key,value_name='ProfileImagePath')'%systemroot%\\\\ServiceProfiles\\\\NetworkService'>>># Create a Key>>>create_key(r'HKCU\\Software\\lib_registry_test')>>># Delete a Key>>>delete_key(r'HKCU\\Software\\lib_registry_test')>>># Write a Value to the Registry>>>create_key(r'HKCU\\Software\\lib_registry_test')>>>set_value(key_name=r'HKCU\\Software\\lib_registry_test',value_name='test_name',value='test_string',value_type=REG_SZ)>>>result=get_value(key_name=r'HKCU\\Software\\lib_registry_test',value_name='test_name')>>>assertresult=='test_string'>>># Delete a Value from the Registry>>>delete_value(key_name=r'HKCU\\Software\\lib_registry_test',value_name='test_name')>>>delete_key(r'HKCU\\Software\\lib_registry_test')>>># Check if a key exists>>>key_exist('HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\S-1-5-20'True>>>key_exist('HKEY_LOCAL_MACHINE\\Software\\DoesNotExist')False>>># get the SID´s of all Windows users>>>get_ls_user_sids()['.DEFAULT','S-1-5-18','S-1-5-19','S-1-5-20',...]>>># get the Username from SID>>>get_username_from_sid(sid='S-1-5-20')'NetworkService'
确认
特别感谢“鲍勃叔叔”罗伯特C马丁,特别是他写的关于“干净代码”和“干净架构”的书
贡献
我希望你能给我这个项目的请求。 请捐款。
更改日志
1.0.2
2019-04-10:初始PYPI发布
1.0.1
2019-03-29:在Linux下导入时防止导入错误
1.0.0
2019-03-28:首次公开发布