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

  • 相关阅读:
    Javascript-DOM
    我的小站成长之路
    Reverse Proxy Vs Forward Proxy
    SSO-单点统一登录系统的设计与实现
    关于网络实名制
    LoggerOne
    AmpOne
    Get a handle on PHP Handlers
    Which PHP mode? Apache vs CGI vs FastCGI
    强制浏览器在点击回退按钮时重载刷新页面
  • 原文地址:https://www.cnblogs.com/shaosks/p/5599980.html
Copyright © 2011-2022 走看看