zoukankan      html  css  js  c++  java
  • python 程序列表

    用 python  通过读取注册表来获取机器安装的程序列表,包括,软件名称,版本号,安装日期等

    # -*- coding: UTF8 -*-
    import _winreg
    import os
    import CommMethod

    1、

    '''获取SOFTWAREMicrosoftWindowsCurrentVersionApp Paths下的程序列表'''
    def GetAppPathsRegeditInfo(list):
      keyPath = r"SOFTWAREMicrosoftWindowsCurrentVersionApp Paths"
      key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, keyPath, 0, _winreg.KEY_ALL_ACCESS)
      listKeys = _winreg.QueryInfoKey(key)
      for i in xrange(0,listKeys[0]-1):
      key_name_list =_winreg.EnumKey(key, i)
      each_key_path = keyPath + '\' + key_name_list
      try:
        each_key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, each_key_path, 0, _winreg.KEY_READ)
        fpath,REG_SZ = _winreg.QueryValueEx(each_key, "")
        fInfo = CommMethod.getFileInfo(fpath)
        list.append(fInfo)
      except:
        continue

    2、

      ''''获取SOFTWAREMicrosoftWindowsCurrentVersionUninstall下的程序列表'''
        def GetUninstallRegeditInfo(list):
          keyPath = r"SOFTWAREMicrosoftWindowsCurrentVersionUninstall"
          key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, keyPath, 0, _winreg.KEY_ALL_ACCESS)
          for i in xrange(0,_winreg.QueryInfoKey(key)[0]-1):
            key_name_list =_winreg.EnumKey(key, i)
            each_key_path = keyPath+'\'+key_name_list
            each_key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, each_key_path, 0, _winreg.KEY_ALL_ACCESS)
            try:
              DisplayName, REG_SZ = _winreg.QueryValueEx(each_key, "DisplayName")
              #DisplayName = DisplayName.encode('utf-8')
              DisplayVersion, REG_SZ = _winreg.QueryValueEx(each_key, "DisplayVersion")
              InstallDate, REG_SZ = _winreg.QueryValueEx(each_key, "InstallDate")
              if (len(DisplayName)>0 and len(DisplayVersion)>0 and len(InstallDate)>0):
                fInfo = CommMethod.SoftwareInfo(DisplayName,InstallDate,DisplayVersion)
                list.append(fInfo)
            except WindowsError:
              pass

  • 相关阅读:
    boboJavaScript中innerHTML,innerText,value
    bobo JS中document.write(" ");
    bobo window.location.href
    bobojQuery选择器总结
    bobo jquery attr()方法
    bobowindow.location.hash 属性使用说明
    bobo$(function(){})和$(document).ready(function(){})
    bobo使用jQuery解析JSON数据
    MyBatis实现CRUD操作
    第一个MyBatis程序
  • 原文地址:https://www.cnblogs.com/shaosks/p/5599980.html
Copyright © 2011-2022 走看看