python类EnumValue()的实例源码

recipe-473846.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def get_shellfolders(branch=HKCU, key=SHELL_FOLDERS):
    """Return mapping of shell folder names (current user) to paths."""

    key = _winreg.OpenKey(branch, key)
    folders = {}
    i = 0
    while True:
        try:
            ret = _winreg.EnumValue(key, i)
            if ret[2] == _winreg.REG_EXPAND_SZ:
                folders[ret[0]] = expandvars(ret[1])
            else:
                folders[ret[0]] = ret[1]
        except WindowsError:
            break
        i +=1
    key.Close()
    return folders
registry.py 文件源码 项目:PythonForWindows 作者: hakril 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def values(self):
        """The values of the registry key

        :type: [:class:`KeyValue`] - A list of values"""
        res = []
        with ExpectWindowsError(259):
            for i in itertools.count():
                name_value_type = _winreg.EnumValue(self.phkey, i)
                # _winreg doest not support REG_QWORD
                # See http://bugs.python.org/issue23026
                if name_value_type[2] == REG_QWORD:
                    name = name_value_type[0]
                    value = struct.unpack("<Q", name_value_type[1])[0]
                    type = name_value_type[2]
                    name_value_type = name, value, type
                res.append(name_value_type)
        return [KeyValue(*r) for r in res]
win32_proxy_manager.py 文件源码 项目:Intranet-Penetration 作者: yuxiaokui 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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)
win32_proxy_manager.py 文件源码 项目:MKFQ 作者: maojingios 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
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)
win32_proxy_manager.py 文件源码 项目:xxNet 作者: drzorm 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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)
test_winsound.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def has_sound(sound):
    """Find out if a particular event is configured with a default sound"""
    try:
        # Ask the mixer API for the number of devices it knows about.
        # When there are no devices, PlaySound will fail.
        if ctypes.windll.winmm.mixerGetNumDevs() is 0:
            return False

        key = _winreg.OpenKeyEx(_winreg.HKEY_CURRENT_USER,
                "AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound))
        value = _winreg.EnumValue(key, 0)[1]
        if value is not u"":
            return True
        else:
            return False
    except WindowsError:
        return False
test_winsound.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def has_sound(sound):
    """Find out if a particular event is configured with a default sound"""
    try:
        # Ask the mixer API for the number of devices it knows about.
        # When there are no devices, PlaySound will fail.
        if ctypes.windll.winmm.mixerGetNumDevs() is 0:
            return False

        key = _winreg.OpenKeyEx(_winreg.HKEY_CURRENT_USER,
                "AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound))
        value = _winreg.EnumValue(key, 0)[1]
        if value is not u"":
            return True
        else:
            return False
    except WindowsError:
        return False
webgobbler.py 文件源码 项目:hachoir3 作者: vstinner 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def loadFromRegistryCurrentUser(self):
        ''' Load configuration from Windows registry. '''
        # We manually build a .INI file in memory from the registry.
        inilines = ['[%s]' % applicationConfig.CONFIG_SECTIONNAME]
        try:
            import _winreg
        except ImportError, exc:
            raise ImportError, "applicationConfig.loadFromRegistryCurrentUser() can only be used under Windows (requires the _winreg module).\nCould not import module because: %s" % exc
        try:
            key = _winreg.OpenKey(
                _winreg.HKEY_CURRENT_USER, applicationConfig.CONFIG_REGPATH, 0, _winreg.KEY_READ)
            # Now get all values in this key:
            i = 0
            try:
                while True:
                    # mmm..strange, Should unpack to 3 values, but seems to
                    # unpack to more.  Bug of EnumValue() ?
                    valueobj = _winreg.EnumValue(key, i)
                    valuename = str(valueobj[0]).strip()
                    valuedata = str(valueobj[1]).strip()
                    valuetype = valueobj[2]
                    if valuetype != _winreg.REG_SZ:
                        raise TypeError, "The registry value %s does not have the correct type (REG_SZ). Please delete it." % valuename
                    else:
                        if valuename not in applicationConfig.NONEXPORTABLE_PARAMETERS:
                            # Build the .INI file.
                            inilines += ['%s=%s' % (valuename, str(valuedata))]
                    i += 1
            except EnvironmentError:
                # EnvironmentError means: "No more values to read". We simply
                # exit the 'While True' loop.
                pass
            # Then parse the generated .INI file.
            self.fromINI('\n'.join(inilines))
        except EnvironmentError:
            raise WindowsError, "Could not read configuration from registry !"
        _winreg.CloseKey(key)
Win-discoverNetworks.py 文件源码 项目:WintersWrath 作者: Elfsong 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def printNets(username, password):
    keypath = r"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkList\\Signatures\\Unmanaged"
    key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, keypath)

    print ('[*] Networks you have joined.')

    for i in range(1):
    try:
        guid = _winreg.EnumKey(key, i)
        netKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, keypath+r"\\"+str(guid))

        (n, addr, t) = _winreg.EnumValue(netKey, 0)
        (n, name, t) = _winreg.EnumValue(netKey, 1)

        macAddr = val2addr(addr)

        print (' [+] ' + name + ' ' + macAddr)

        #wiglePrint(username, password, macAddr)
            _winreg.CloseKey(netKey)

    except Exception, e:
            print e
        break
win32_proxy_manager.py 文件源码 项目:Docker-XX-Net 作者: kuanghy 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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)
Windows.py 文件源码 项目:keyrings.alt 作者: jaraco 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def _delete_key_if_empty(self, service):
        key_name = r'Software\%s\Keyring' % service
        key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_name, 0,
            winreg.KEY_ALL_ACCESS)
        try:
            winreg.EnumValue(key, 0)
            return
        except WindowsError:
            pass
        winreg.CloseKey(key)

        # it's empty; delete everything
        while key_name != 'Software':
            parent, sep, base = key_name.rpartition('\\')
            key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, parent, 0,
                winreg.KEY_ALL_ACCESS)
            winreg.DeleteKey(key, base)
            winreg.CloseKey(key)
            key_name = parent
recipe-498148.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __del_values(self):
        'Private class method.'
        try:
            while True:
                _winreg.DeleteValue(self.__self, _winreg.EnumValue(self.__self, 0)[0])
        except EnvironmentError:
            pass
recipe-498148.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __iter__(self):
        'Iterate over the value names.'
        values, index = [], 0
        try:
            while True:
                values.append(_winreg.EnumValue(self.__self, index)[0])
                index += 1
        except EnvironmentError:
            for value in values:
                yield value
recipe-498148.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __contains__(self, item):
        'Check for a value\'s existence.'
        item, index = item.lower(), 0
        try:
            while True:
                if _winreg.EnumValue(self.__self, index)[0].lower() == item:
                    return True
                index += 1
        except EnvironmentError:
            return False
recipe-502268.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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
recipe-578209.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def __del_values(self):
        'Private class method.'
        try:
            while True:
                _winreg.DeleteValue(self.__key, _winreg.EnumValue(self.__key, 0)[0])
        except EnvironmentError:
            pass
recipe-578209.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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

################################################################################
recipe-510392.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __del_values(self):
        'Private class method.'
        try:
            while True:
                _winreg.DeleteValue(self.__key, _winreg.EnumValue(self.__key, 0)[0])
        except EnvironmentError:
            pass
recipe-510392.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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])))
recipe-510392.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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

################################################################################
recipe-476229.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def enumvalue(self, index):
            """ Enumerate the values of the currently open key """

            if not self._hkey: raise RegistryError,"Error: null key"
            try:
                return wreg.EnumValue(self._hkey, index)
            except EnvironmentError, e:
                raise RegistryError, e
_win32.py 文件源码 项目:sndlatr 作者: Schibum 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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
win32timezone.py 文件源码 项目:purelove 作者: hucmosin 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _enumerate_reg_values(key):
        return _RegKeyDict._enumerate_reg(key, _winreg.EnumValue)
win32_proxy_manager.py 文件源码 项目:Intranet-Penetration 作者: yuxiaokui 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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)
win32_proxy_manager.py 文件源码 项目:MKFQ 作者: maojingios 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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)
cpuinfo.py 文件源码 项目:aerospike-telemetry-agent 作者: aerospike 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def __init__(self):
        if self.info is not None:
            return
        info = []
        try:
            #XXX: Bad style to use so long `try:...except:...`. Fix it!
            import _winreg
            prgx = re.compile(r"family\s+(?P<FML>\d+)\s+model\s+(?P<MDL>\d+)"\
                              "\s+stepping\s+(?P<STP>\d+)",re.IGNORECASE)
            chnd=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, self.pkey)
            pnum=0
            while 1:
                try:
                    proc=_winreg.EnumKey(chnd,pnum)
                except _winreg.error:
                    break
                else:
                    pnum+=1
                    info.append({"Processor":proc})
                    phnd=_winreg.OpenKey(chnd,proc)
                    pidx=0
                    while True:
                        try:
                            name,value,vtpe=_winreg.EnumValue(phnd,pidx)
                        except _winreg.error:
                            break
                        else:
                            pidx=pidx+1
                            info[-1][name]=value
                            if name=="Identifier":
                                srch=prgx.search(value)
                                if srch:
                                    info[-1]["Family"]=int(srch.group("FML"))
                                    info[-1]["Model"]=int(srch.group("MDL"))
                                    info[-1]["Stepping"]=int(srch.group("STP"))
        except:
            print sys.exc_value,'(ignoring)'
        self.__class__.info = info
tzwin.py 文件源码 项目:Crunchyroll-XML-Decoder 作者: jaw20 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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
win32.py 文件源码 项目:respeaker_virtualenv 作者: respeaker 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
wingetports.py 文件源码 项目:driveboardapp 作者: nortd 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def portiter():
    key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, b'HARDWARE\\DEVICEMAP\\SERIALCOMM') # open the registry
    i = 0
    while True: # loop until we run out of devices
        try:
            name = bytes(winreg.EnumValue(key, i)[1]) # get the device name
            # EnumValue gets item number i, returning a tuple containing the name in position 1
        except OSError: # that's all the devices
            break
        yield name, port_prefix + name
        i += 1
_win32.py 文件源码 项目:chalktalk_docs 作者: loremIpsum1771 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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


问题


面经


文章

微信
公众号

扫码关注公众号