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
评论列表
文章目录