python获取软件安装列表2222

softer_installed_list =====================

运用python编写的,获取本机软件设置列表,输出为html表格.

* win7 32位环境下运作

*
使用的是”**SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall**”

下的软件安装列表

* 生成文件保留为index.html

* 示例地址:http://sharedoc.sinaapp.com/install-list/

* gitbhub地址为:https://github.com/urmyfaith/softer\_installed\_list/

* 运行不要求参数,双击softer_installed_list.py即可.(须求设置python2.x)

关键代码:

“`python key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
r”SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”, 0,
_winreg.KEY_ALL_ACCESS) for i in xrange(0,
_winreg.QueryInfoKey(key)[0]-1): try:
key_name_under_uninstall=_winreg.EnumKey(key, i) #print
key_name_under_uninstall
each_key_path=”SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”+’\\’+
key_name_under_uninstall #print each_key_path each_key=
_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,each_key_path,0,
_winreg.KEY_ALL_ACCESS) try: softer_ware_name,typeresult=
_winreg.QueryValueEx(each_key,”DisplayName”)
softer_ware_name=softer_ware_name.encode(‘utf-8’)

try: InstallLocation_name,typeresult=
_winreg.QueryValueEx(each_key,”InstallLocation”) InstallLocation_name
= InstallLocation_name.encode(‘utf-8’) if InstallLocation_name==””:
InstallLocation_name=”NULL” except WindowsError:
InstallLocation_name=”NULL” html_table = html_table +
html_tr_left_str + str(i+1) + ””” + softer_ware_name + ””” +
InstallLocation_name + html_tr_right_str except WindowsError: pass
except WindowsError: pass

“`

相关文章