Python _winreg 模块,QueryInfoKey() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用_winreg.QueryInfoKey()

项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def disable_proxy():
    _,values_num,_ = winreg.QueryInfoKey(CONNECTIONS)
    for i in range(0, values_num):
        try:
            key, value,_ = winreg.EnumValue(CONNECTIONS, i)
        except:
            break

        List = INTERNET_PER_CONN_OPTION_LIST()
        Option = (INTERNET_PER_CONN_OPTION * 1)()
        nSize = c_ulong(sizeof(INTERNET_PER_CONN_OPTION_LIST))

        Option[0].dwOption = INTERNET_PER_CONN_FLAGS
        Option[0].Value.dwValue = PROXY_TYPE_DIRECT

        List.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST)
        List.pszConnection = create_unicode_buffer(key)
        List.dwOptionCount = 1
        List.dwOptionError = 0
        List.pOptions = Option

        InternetSetOption(None, INTERNET_OPTION_PER_CONNECTION_OPTION, byref(List), nSize)

    InternetSetOption(None, INTERNET_OPTION_SETTINGS_CHANGED, None, 0)
    InternetSetOption(None, INTERNET_OPTION_REFRESH, None, 0)
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def disable_proxy():
    _,values_num,_ = winreg.QueryInfoKey(CONNECTIONS)
    for i in range(0, values_num):
        try:
            key, value,_ = winreg.EnumValue(CONNECTIONS, i)
        except:
            break

        List = INTERNET_PER_CONN_OPTION_LIST()
        Option = (INTERNET_PER_CONN_OPTION * 1)()
        nSize = c_ulong(sizeof(INTERNET_PER_CONN_OPTION_LIST))

        Option[0].dwOption = INTERNET_PER_CONN_FLAGS
        Option[0].Value.dwValue = PROXY_TYPE_DIRECT

        List.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST)
        List.pszConnection = create_unicode_buffer(key)
        List.dwOptionCount = 1
        List.dwOptionError = 0
        List.pOptions = Option

        InternetSetOption(None, INTERNET_OPTION_PER_CONNECTION_OPTION, byref(List), nSize)

    InternetSetOption(None, INTERNET_OPTION_SETTINGS_CHANGED, None, 0)
    InternetSetOption(None, INTERNET_OPTION_REFRESH, None, 0)
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def disable_proxy():
    _,values_num,_ = winreg.QueryInfoKey(CONNECTIONS)
    for i in range(0, values_num):
        try:
            key, value,_ = winreg.EnumValue(CONNECTIONS, i)
        except:
            break

        List = INTERNET_PER_CONN_OPTION_LIST()
        Option = (INTERNET_PER_CONN_OPTION * 1)()
        nSize = c_ulong(sizeof(INTERNET_PER_CONN_OPTION_LIST))

        Option[0].dwOption = INTERNET_PER_CONN_FLAGS
        Option[0].Value.dwValue = PROXY_TYPE_DIRECT

        List.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST)
        List.pszConnection = create_unicode_buffer(key)
        List.dwOptionCount = 1
        List.dwOptionError = 0
        List.pOptions = Option

        InternetSetOption(None, INTERNET_OPTION_PER_CONNECTION_OPTION, byref(List), nSize)

    InternetSetOption(None, INTERNET_OPTION_SETTINGS_CHANGED, None, 0)
    InternetSetOption(None, INTERNET_OPTION_REFRESH, None, 0)
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
def disable_proxy():
    _,values_num,_ = winreg.QueryInfoKey(CONNECTIONS)
    for i in range(0, values_num):
        try:
            key, value,_ = winreg.EnumValue(CONNECTIONS, i)
        except:
            break

        List = INTERNET_PER_CONN_OPTION_LIST()
        Option = (INTERNET_PER_CONN_OPTION * 1)()
        nSize = c_ulong(sizeof(INTERNET_PER_CONN_OPTION_LIST))

        Option[0].dwOption = INTERNET_PER_CONN_FLAGS
        Option[0].Value.dwValue = PROXY_TYPE_DIRECT

        List.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST)
        List.pszConnection = create_unicode_buffer(key)
        List.dwOptionCount = 1
        List.dwOptionError = 0
        List.pOptions = Option

        InternetSetOption(None, INTERNET_OPTION_PER_CONNECTION_OPTION, byref(List), nSize)

    InternetSetOption(None, INTERNET_OPTION_SETTINGS_CHANGED, None, 0)
    InternetSetOption(None, INTERNET_OPTION_REFRESH, None, 0)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __get_info(self):
        'Private class method.'
        return Info(*_winreg.QueryInfoKey(self.__self))
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __len__(self):
        'Return the number of keys.'
        return _winreg.QueryInfoKey(self.__self)[0]
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __len__(self):
        'Return the number of values.'
        return _winreg.QueryInfoKey(self.__self)[1]
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def keys(self):
        # returns a dict of subkeys
        if not self._keys:
            self._keys={}
            for i in xrange(reg.QueryInfoKey(self.wrk)[0]):
                name=reg.EnumKey(self.wrk, i).lower()
                try:
                    self._keys[name]=Key(self, name)
                except WindowsError: pass
        return self._keys
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def vals(self):
        # returns the list of values
        if not self._vals:
            self._vals=[]
            for i in xrange(reg.QueryInfoKey(self.wrk)[1]):
                try:
                    self._vals.append(Val(self, *reg.EnumValue(self.wrk, i)))
                except WindowsError: pass
        return self._vals
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __len__(self):
        'Return the number of keys.'
        return _winreg.QueryInfoKey(self.__key)[0]
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __iter__(self):
        'Iterate over the key names.'
        return iter(tuple(_winreg.EnumKey(self.__key, index) for index in xrange(_winreg.QueryInfoKey(self.__key)[0])))
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __contains__(self, item):
        'Check for a key\'s existence.'
        item = item.lower()
        for index in xrange(_winreg.QueryInfoKey(self.__key)[0]):
            if _winreg.EnumKey(self.__key, index).lower() == item:
                return True
        return False

################################################################################
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __len__(self):
        'Return the number of values.'
        return _winreg.QueryInfoKey(self.__key)[1]
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __iter__(self):
        'Iterate over the value names.'
        return iter(tuple(_winreg.EnumValue(self.__key, index)[0] for index in xrange(_winreg.QueryInfoKey(self.__key)[1])))
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __get_keys(self):
        'Private class method.'
        return _winreg.QueryInfoKey(self.__key)[0]
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __get_values(self):
        'Private class method.'
        return _winreg.QueryInfoKey(self.__key)[1]
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __get_modified(self):
        'Private class method.'
        return _winreg.QueryInfoKey(self.__key)[2]
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __get_info(self):
        'Private class method.'
        return Info(*_winreg.QueryInfoKey(self.__key))
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __len__(self):
        'Return the number of keys.'
        return _winreg.QueryInfoKey(self.__key)[0]
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __contains__(self, item):
        'Check for a key\'s existence.'
        item = item.lower()
        for index in xrange(_winreg.QueryInfoKey(self.__key)[0]):
            if _winreg.EnumKey(self.__key, index).lower() == item:
                return True
        return False

################################################################################
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __len__(self):
        'Return the number of values.'
        return _winreg.QueryInfoKey(self.__key)[1]
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __iter__(self):
        'Iterate over the value names.'
        return iter(tuple(_winreg.EnumValue(self.__key, index)[0] for index in xrange(_winreg.QueryInfoKey(self.__key)[1])))
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __contains__(self, item):
        'Check for a value\'s existence.'
        item = item.lower()
        for index in xrange(_winreg.QueryInfoKey(self.__key)[1]):
            if _winreg.EnumValue(self.__key, index)[0].lower() == item:
                return True
        return False

################################################################################
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def GetExtensionInfo(pExtension):
    lHandle = reg.OpenKey(reg.HKEY_CLASSES_ROOT, pExtension)
    lSubKeys, lValueCount, lModified = reg.QueryInfoKey(lHandle)
    lValues = {}
    for lCount in range(0, lValueCount):
        lName, lValue, lType = reg.EnumValue(lHandle, lCount)
        if lName == '':
            lName = "File Type"
        lValues[lName] =lValue

    lKey = lValues['File Type']
    lDescription = reg.QueryValue(reg.HKEY_CLASSES_ROOT, lKey)
    lValues['Description'] = lDescription

    lKey += '\\Shell'
    lDefault = reg.QueryValue(reg.HKEY_CLASSES_ROOT, lKey)
    lValues['Default'] = lDefault    

    return lValues
项目:sndlatr    作者:Schibum    | 项目源码 | 文件源码
def valuestodict(key):
    """Convert a registry key's values to a dictionary."""
    dict = {}
    size = winreg.QueryInfoKey(key)[1]
    for i in range(size):
        data = winreg.EnumValue(key, i)
        dict[data[0]] = data[1]
    return dict
项目:PythonForWindows    作者:hakril    | 项目源码 | 文件源码
def info(self):
        return _winreg.QueryInfoKey(self.phkey)
项目:csm    作者:gnzsystems    | 项目源码 | 文件源码
def remove_certificate(self, certificate):
        CONTAINS_SUBKEYS = 0
        registryHandles = []
        returnValue = False
        path = certificate["RegPath"].split("/")
        hiveName = path.pop(0)
        keyName = path.pop(-1)
        hive = reg.ConnectRegistry(None, self.regKeys[hiveName][0])
        registryHandle = reg.OpenKey(hive, self.regKeys[hiveName][1])
        self._log("Connected to registry at location: %s" % hiveName)
        for step in path:
            registryHandles.append(registryHandle)
            registryHandle = reg.OpenKey(registryHandle, step)
        try:
            deletionCandidate = reg.OpenKey(registryHandle, keyName)
            self._log("Querying deletion canditate: %s" % certificate["RegPath"])
            if not reg.QueryInfoKey(deletionCandidate)[CONTAINS_SUBKEYS]:
                self._log("Attempting to delete key: %s" % certificate["RegPath"])
                reg.CloseKey(deletionCandidate)
                reg.DeleteKey(registryHandle, keyName)
                self._log("Deleted key: %s" % certificate["RegPath"])
                returnValue = True
            else:
                self._error_log("Unable to delete key: %s.  Key  contains subkeys." % certificate["RegPath"])
                registryHandles.append(deletionCandidate)
                raise WindowsError
        except WindowsError as e:
            self._error_log("Unable to delete key: %s.  Windows error." % certificate["RegPath"])
            self._error_log("%s: %s" % (certificate["RegPath"], str(e)))
            pass
        self._log("Closing registry handles...")
        for handle in registryHandles:
            reg.CloseKey(handle)
        reg.CloseKey(hive)
        self._log("Registry handles closed.")
        return returnValue
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def set_proxy(proxy_addr):
    _,values_num,_ = winreg.QueryInfoKey(CONNECTIONS)
    if values_num:
        for i in range(0, values_num):
            try:
                key,value,_ = winreg.EnumValue(CONNECTIONS, i)
            except:
                break

            if '://' in proxy_addr:
                set_proxy_auto(proxy_addr, key)
            else:
                set_proxy_server(proxy_addr, key)
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def set_proxy(proxy_addr):
    _,values_num,_ = winreg.QueryInfoKey(CONNECTIONS)
    if values_num:
        for i in range(0, values_num):
            try:
                key,value,_ = winreg.EnumValue(CONNECTIONS, i)
            except:
                break

            if '://' in proxy_addr:
                set_proxy_auto(proxy_addr, key)
            else:
                set_proxy_server(proxy_addr, key)
项目:Crunchyroll-XML-Decoder    作者:jaw20    | 项目源码 | 文件源码
def list():
        """Return a list of all time zones known to the system."""
        handle = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
        tzkey = _winreg.OpenKey(handle, TZKEYNAME)
        result = [_winreg.EnumKey(tzkey, i)
                  for i in range(_winreg.QueryInfoKey(tzkey)[0])]
        tzkey.Close()
        handle.Close()
        return result
项目:Crunchyroll-XML-Decoder    作者:jaw20    | 项目源码 | 文件源码
def valuestodict(key):
    """Convert a registry key's values to a dictionary."""
    dict = {}
    size = _winreg.QueryInfoKey(key)[1]
    for i in range(size):
        data = _winreg.EnumValue(key, i)
        dict[data[0]] = data[1]
    return dict
项目:respeaker_virtualenv    作者:respeaker    | 项目源码 | 文件源码
def valuestodict(key):
    """Convert a registry key's values to a dictionary."""
    dict = {}
    size = winreg.QueryInfoKey(key)[1]
    for i in range(size):
        data = winreg.EnumValue(key, i)
        dict[data[0]] = data[1]
    return dict
项目:chalktalk_docs    作者:loremIpsum1771    | 项目源码 | 文件源码
def valuestodict(key):
    """Convert a registry key's values to a dictionary."""
    dict = {}
    size = winreg.QueryInfoKey(key)[1]
    for i in range(size):
        data = winreg.EnumValue(key, i)
        dict[data[0]] = data[1]
    return dict
项目:alexa-apple-calendar    作者:zanderxyz    | 项目源码 | 文件源码
def valuestodict(key):
    """Convert a registry key's values to a dictionary."""
    dict = {}
    size = winreg.QueryInfoKey(key)[1]
    for i in range(size):
        data = winreg.EnumValue(key, i)
        dict[data[0]] = data[1]
    return dict
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def set_proxy(proxy_addr):
    _,values_num,_ = winreg.QueryInfoKey(CONNECTIONS)
    if values_num:
        for i in range(0, values_num):
            try:
                key,value,_ = winreg.EnumValue(CONNECTIONS, i)
            except:
                break

            if '://' in proxy_addr:
                set_proxy_auto(proxy_addr, key)
            else:
                set_proxy_server(proxy_addr, key)
项目:python-card-me    作者:tBaxter    | 项目源码 | 文件源码
def valuesToDict(key):
    """Convert a registry key's values to a dictionary."""
    dict={}
    size=_winreg.QueryInfoKey(key)[1]
    for i in xrange(size):
        dict[_winreg.EnumValue(key, i)[0]]=_winreg.EnumValue(key, i)[1]
    return dict
项目:Panorama    作者:AlmCo    | 项目源码 | 文件源码
def readValues(keyPath):
    # return Dict of name:value from key
    explorer = OpenKey(HKEY_LOCAL_MACHINE, keyPath, 0, KEY_READ | KEY_WOW64_64KEY)
    valuesDict = {}
    for i in range(QueryInfoKey(explorer)[1]):
        name, value, type = EnumValue(explorer, i)
        valuesDict[name] = value
    return valuesDict
项目:Panorama    作者:AlmCo    | 项目源码 | 文件源码
def readKeys(keyPath):
    # return list of Keys
    explorer = OpenKey(HKEY_LOCAL_MACHINE, keyPath, 0, KEY_READ | KEY_WOW64_64KEY)
    KeysList = []
    for i in xrange(QueryInfoKey(explorer)[0]):
        name = EnumKey(explorer, i)
        KeysList.append(name)
    return KeysList
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def get_acroversion():
    " Return version of Adobe Acrobat executable or None"
    import _winreg
    adobesoft = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'Software\Adobe')
    for index in range(_winreg.QueryInfoKey(adobesoft)[0]):
        key = _winreg.EnumKey(adobesoft, index)
        if "acrobat" in key.lower():
            acrokey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s' % key)
            for index in range(_winreg.QueryInfoKey(acrokey)[0]):
                numver = _winreg.EnumKey(acrokey, index)
                try:
                    res = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s\\%s\\InstallPath' % (key, numver))
                    return res
                except Exception:
                    pass
    return None
项目:keypirinha-plugins    作者:EhsanKia    | 项目源码 | 文件源码
def __len__(self):
        """len() gives the number of values and subkeys."""
        info = _winreg.QueryInfoKey(self.hkey)
        return info[0] + info[1]
项目:keypirinha-plugins    作者:EhsanKia    | 项目源码 | 文件源码
def __len__(self):
        return _winreg.QueryInfoKey(self.key.hkey)[0]
项目:keypirinha-plugins    作者:EhsanKia    | 项目源码 | 文件源码
def __len__(self):
        return _winreg.QueryInfoKey(self.key.hkey)[1]
项目:metrics    作者:Jeremy-Friedman    | 项目源码 | 文件源码
def valuestodict(key):
    """Convert a registry key's values to a dictionary."""
    dict = {}
    size = winreg.QueryInfoKey(key)[1]
    for i in range(size):
        data = winreg.EnumValue(key, i)
        dict[data[0]] = data[1]
    return dict
项目:metrics    作者:Jeremy-Friedman    | 项目源码 | 文件源码
def valuestodict(key):
    """Convert a registry key's values to a dictionary."""
    dict = {}
    size = winreg.QueryInfoKey(key)[1]
    for i in range(size):
        data = winreg.EnumValue(key, i)
        dict[data[0]] = data[1]
    return dict
项目:enkiWS    作者:juliettef    | 项目源码 | 文件源码
def valuestodict(key):
    """Convert a registry key's values to a dictionary."""
    dict = {}
    size = winreg.QueryInfoKey(key)[1]
    for i in range(size):
        data = winreg.EnumValue(key, i)
        dict[data[0]] = data[1]
    return dict
项目:django-learning    作者:adoggie    | 项目源码 | 文件源码
def getRegisterValueInAutoRun(key='audioTerm'):
    import _winreg
    try:
        r = _winreg.OpenKey(
                 _winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run")

        p1,num,p3 = _winreg.QueryInfoKey(r)
        for n in range(num):
            p1,p2,p3 =  _winreg.EnumValue(r,n)
            if p1 == key:
                return p2
    except:
        traceback.print_exc()
        return None
项目:django-learning    作者:adoggie    | 项目源码 | 文件源码
def getRegisterValueInAutoRun(key='audioTerm'):
    import _winreg
    try:
        r = _winreg.OpenKey(
                 _winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run")

        p1,num,p3 = _winreg.QueryInfoKey(r)
        for n in range(num):
            p1,p2,p3 =  _winreg.EnumValue(r,n)
            if p1 == key:
                return p2
    except:
        traceback.print_exc()
        return None
项目:FMoviesPlus.bundle    作者:coder-alpha    | 项目源码 | 文件源码
def valuestodict(key):
    """Convert a registry key's values to a dictionary."""
    dict = {}
    size = winreg.QueryInfoKey(key)[1]
    for i in range(size):
        data = winreg.EnumValue(key, i)
        dict[data[0]] = data[1]
    return dict
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
def set_proxy(proxy_addr):
    _,values_num,_ = winreg.QueryInfoKey(CONNECTIONS)
    if values_num:
        for i in range(0, values_num):
            try:
                key,value,_ = winreg.EnumValue(CONNECTIONS, i)
            except:
                break

            if '://' in proxy_addr:
                set_proxy_auto(proxy_addr, key)
            else:
                set_proxy_server(proxy_addr, key)
项目:vobject    作者:eventable    | 项目源码 | 文件源码
def valuesToDict(key):
    """Convert a registry key's values to a dictionary."""
    dict={}
    size=_winreg.QueryInfoKey(key)[1]
    for i in xrange(size):
        dict[_winreg.EnumValue(key, i)[0]]=_winreg.EnumValue(key, i)[1]
    return dict