python类EnumValue()的实例源码

test_winsound.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 24 收藏 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 "":
            return True
        else:
            return False
    except WindowsError:
        return False
mapiex.py 文件源码 项目:nsf2x 作者: adb014 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def CoCreateInstanceC2R (self, store, reg, clsid, iid) :
        # Ugly code to find DLL in C2R version of COM object and get a COM
        # object despite the fact that COM doesn't handle C2R
        try:
            # Get DLL to load from 2R register 
            aReg = winreg.ConnectRegistry(None, store)
            aKey = winreg.OpenKey(aReg, reg, 0, winreg.KEY_READ | winreg.KEY_WOW64_64KEY)
            dummy_n, IconvDLL, dummy_t = winreg.EnumValue(aKey, 0)
            winreg.CloseKey(aKey)
            winreg.CloseKey(aReg)

            # Create OLE object from DLL
            IconvOLE = ctypes.OleDLL(IconvDLL)

            # Get COM Instance from OLE 
            clsid_class = uuid.UUID(str(clsid)).bytes_le
            iclassfactory = uuid.UUID(str(pythoncom.IID_IClassFactory)).bytes_le
            com_classfactory = ctypes.c_long(0)
            IconvOLE.DllGetClassObject(clsid_class, iclassfactory, ctypes.byref(com_classfactory))
            MyFactory = pythoncom.ObjectFromAddress(com_classfactory.value, pythoncom.IID_IClassFactory)
            return MyFactory.CreateInstance (None, str(iid))
        except:
            return None
Windows.py 文件源码 项目:keyrings.alt 作者: jaraco 项目源码 文件源码 阅读 21 收藏 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
Windows.py 文件源码 项目:lib9 作者: Jumpscale 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def enumRegKeyValues(self, key):
        """List all values of a specified key in the windows registry

        @param key: The registry key to check. The key should include the section. Eg. "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion"
        @type key: string

        @return: An array of tupples containing the name of each value, the data of the value and it's type
        @rtype: tupple(string, WinRegValueType)
        """
        hkey, key = self._getHiveAndKey(key)
        aReg = reg.ConnectRegistry(None, hkey)
        aKey = reg.OpenKey(aReg, key)
        result = []
        index = 0

        # The function EnumValue() retrieves the name of one subkey each time it is called.
        # It is typically called repeatedly, until an EnvironmentError exception
        # is raised, indicating no more values.
        while True:
            try:
                valueName, valueData, valueType = reg.EnumValue(aKey, index)
                result.append((valueName, valueData, WinRegValueType.findByIntegerValue(valueType)))
                index += 1
            except EnvironmentError:
                return result
_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
win32.py 文件源码 项目:respeaker_virtualenv 作者: respeaker 项目源码 文件源码 阅读 32 收藏 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 项目源码 文件源码 阅读 26 收藏 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 项目源码 文件源码 阅读 21 收藏 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
test_winsound.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 25 收藏 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() == 0:
            return False

        key = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER,
                "AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound))
        return winreg.EnumValue(key, 0)[1] != ""
    except WindowsError:
        return False
win32.py 文件源码 项目:alexa-apple-calendar 作者: zanderxyz 项目源码 文件源码 阅读 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
winreg.py 文件源码 项目:c4d-plugin-installer 作者: NiklasRosenstein 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def enum(key):
  with open(key) as handle:
    index = 0
    while True:
      try:
        yield Key(*winreg.EnumValue(handle, index))
        index += 1
      except WindowsError:
        break
win32timezone.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _enumerate_reg_values(key):
        return _RegKeyDict._enumerate_reg(key, winreg.EnumValue)
addtoregistry.py 文件源码 项目:SDV-Summary 作者: Sketchy502 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def check_startup():
    key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 0, winreg.KEY_READ)
    i = 0
    while True:
        try:
            a = winreg.EnumValue(key,i)
            i+=1
            if a[0] == REGISTRY_NAME:
                return True
        except OSError:
            break
    key.Close()
    return False
test_winsound.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 26 收藏 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() == 0:
            return False

        key = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER,
                "AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound))
        return winreg.EnumValue(key, 0)[1] != ""
    except OSError:
        return False
regobj.py 文件源码 项目:keypirinha-plugins 作者: EhsanKia 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def next(self):
        try:
            v = _winreg.EnumValue(self.key.hkey,self.index)
        except WindowsError:
            raise StopIteration
        else:
            self.index += 1
            return Value(v[1],v[0],v[2])
win32.py 文件源码 项目:metrics 作者: Jeremy-Friedman 项目源码 文件源码 阅读 27 收藏 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 文件源码 项目:metrics 作者: Jeremy-Friedman 项目源码 文件源码 阅读 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
nsf2x.py 文件源码 项目:nsf2x 作者: adb014 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def OutlookPath():
    """Function to retrieve the path to Outlook from the registry"""
    aReg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
    aKey = winreg.OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE")
    # prepend unused variables with "dummy_" to keep PyLint happy
    dummy_n, v, dummy_t = winreg.EnumValue(aKey, 0)
    winreg.CloseKey(aKey)
    winreg.CloseKey(aReg)
    return v
_win32.py 文件源码 项目:enkiWS 作者: juliettef 项目源码 文件源码 阅读 21 收藏 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
test_winsound.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 31 收藏 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() == 0:
            return False

        key = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER,
                "AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound))
        return winreg.EnumValue(key, 0)[1] != ""
    except OSError:
        return False
win32.py 文件源码 项目:FMoviesPlus.bundle 作者: coder-alpha 项目源码 文件源码 阅读 21 收藏 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
WinEnum.py 文件源码 项目:WindowsEnumeration 作者: tdmathison 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def walk_registry(hkey, path, access_flags, keywords, onerror=None):
    """ Walks all keys of the registry searching for values that match any of the provided 'keywords'. """
    try:
        key = winreg.OpenKey(hkey, path, access_flags)
    except OSError as e:
        if onerror is not None:
            onerror(e)
        return

    i = 0
    sub_keys = []
    with key:
        while True:
            try:
                sub_keys.append(winreg.EnumKey(key, i))
            except OSError:
                break
            i += 1

        i = 0
        while True:
            try:
                data = winreg.EnumValue(key, i)
                i += 1
                for keyword in keywords:
                    if keyword.lower() in str(data[0]).lower():
                        if hkey == winreg.HKEY_LOCAL_MACHINE:
                            hive = 'HKLM\\'
                        else:
                            hive = 'HKCU\\'

                        print('{0}\\{1}\\{2} = {3}'.format(hive, path, data[0], data[1]))
            except OSError:
                break

        for key in sub_keys:
            next_path = os.path.join(path, key)
            for item in walk_registry(hkey, next_path, access_flags, keywords, onerror):
                yield item
_win32.py 文件源码 项目:Hawkeye 作者: tozhengxq 项目源码 文件源码 阅读 26 收藏 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 文件源码 项目:Alfred 作者: jkachhadia 项目源码 文件源码 阅读 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
cpuinfo.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 29 收藏 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!
            if sys.version_info[0] >= 3:
                import winreg
            else:
                import _winreg as 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 True:
                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_info()[1], '(ignoring)')
        self.__class__.info = info
cpuinfo.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 29 收藏 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!
            if sys.version_info[0] >= 3:
                import winreg
            else:
                import _winreg as 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 True:
                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_info()[1], '(ignoring)')
        self.__class__.info = info
cpuinfo.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 38 收藏 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!
            if sys.version_info[0] >= 3:
                import winreg
            else:
                import _winreg as 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 True:
                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_info()[1], '(ignoring)')
        self.__class__.info = info
cpuinfo.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 32 收藏 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!
            if sys.version_info[0] >= 3:
                import winreg
            else:
                import _winreg as 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 True:
                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_info()[1], '(ignoring)')
        self.__class__.info = info
cpuinfo.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 26 收藏 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!
            if sys.version_info[0] >= 3:
                import winreg
            else:
                import _winreg as 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 True:
                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_info()[1], '(ignoring)')
        self.__class__.info = info
cpuinfo.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 31 收藏 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!
            if sys.version_info[0] >= 3:
                import winreg
            else:
                import _winreg as winreg

            prgx = re.compile(r"family\s+(?P<FML>\d+)\s+model\s+(?P<MDL>\d+)"
                              r"\s+stepping\s+(?P<STP>\d+)", re.IGNORECASE)
            chnd=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, self.pkey)
            pnum=0
            while True:
                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_info()[1], '(ignoring)')
        self.__class__.info = info


问题


面经


文章

微信
公众号

扫码关注公众号