registry_utils.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:r2com 作者: newlog 项目源码 文件源码
def __get_data(root_key, key, value):
    """This method gets the data from the given key and value under the root
    key.

    Args:
      root_key (str): The root key as abbreviated string.
                      Valid values: [hklm, hkcr, hkcu, hku, hkpd, hkcc].
      key (str): The subkey starting from the root key.
              e.g.: SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
      value (str): The value to query.

    Returns:
      Str. It returns the retrieved data, or an empty string if data could not be retrieved.
    """
    data = ''
    try:
      hkey = _winreg.OpenKey(root_key, key, 0, _winreg.KEY_READ)
      data, regtype = _winreg.QueryValueEx(hkey, value)
      _winreg.CloseKey(hkey)
    except WindowsError as e:
      logging.error('Error occurred getting registry data: {0}'.format(e))
    return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号