当前位置: 首页>>代码示例>>Python>>正文


Python _winreg.EnumKey方法代码示例

本文整理汇总了Python中_winreg.EnumKey方法的典型用法代码示例。如果您正苦于以下问题:Python _winreg.EnumKey方法的具体用法?Python _winreg.EnumKey怎么用?Python _winreg.EnumKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在_winreg的用法示例。


在下文中一共展示了_winreg.EnumKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: WIN_get_device_guid

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import EnumKey [as 别名]
def WIN_get_device_guid(self):

		try:
			regkey = registry.OpenKey(registry.HKEY_LOCAL_MACHINE, self.WINDOWS_ADAPTER_KEY)
			for i in xrange(10000):
				key_name = registry.EnumKey(regkey, i)
				try:
					regsubkey = registry.OpenKey(regkey, key_name)
					component_id = registry.QueryValueEx(regsubkey, "ComponentId")[0]
					if component_id == self.TUNTAP_COMPONENT_ID:
						return registry.QueryValueEx(regsubkey, 'NetCfgInstanceId')[0]
				except WindowsError as e:
					pass
					continue
		except Exception as e:
			pass
			return None

		return None 
开发者ID:earthquake,项目名称:XFLTReaT,代码行数:21,代码来源:interface.py

示例2: get_device_guid

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import EnumKey [as 别名]
def get_device_guid():
    with reg.OpenKey(reg.HKEY_LOCAL_MACHINE, adapter_key) as adapters:
        try:
            for i in xrange(10000):
                key_name = reg.EnumKey(adapters, i)
                with reg.OpenKey(adapters, key_name) as adapter:
                    try:
                        component_id = reg.QueryValueEx(adapter, 'ComponentId')[0]
                        # print component_id
                        # if component_id == 'tap0801':
                        if component_id == 'tap0901':
                            regid = reg.QueryValueEx(adapter, 'NetCfgInstanceId')[0]
                            return 'regid:', regid
                    except WindowsError, err:
                        pass
        except WindowsError, err:
            pass 
开发者ID:alexsunday,项目名称:pyvpn,代码行数:19,代码来源:tun-ping-win.py

示例3: test_non_latin_extension

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import EnumKey [as 别名]
def test_non_latin_extension(self):
        import _winreg

        class MockWinreg(object):
            def __getattr__(self, name):
                if name == 'EnumKey':
                    return lambda key, i: _winreg.EnumKey(key, i) + "\xa3"
                elif name == 'OpenKey':
                    return lambda key, name: _winreg.OpenKey(key, name.rstrip("\xa3"))
                elif name == 'QueryValueEx':
                    return lambda subkey, label: (u'текст/простой' , _winreg.REG_SZ)
                return getattr(_winreg, name)

        mimetypes._winreg = MockWinreg()
        try:
            # this used to throw an exception if registry contained non-Latin
            # characters in extensions (issue #9291)
            mimetypes.init()
        finally:
            mimetypes._winreg = _winreg 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_mimetypes.py

示例4: uninstall_all

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import EnumKey [as 别名]
def uninstall_all():
    """uninstalls PyXLL from all installed Excel versions"""
    for wow64_flags in (winreg.KEY_WOW64_64KEY, winreg.KEY_WOW64_32KEY):
        for root in _root_keys.keys():
            try:
                flags = wow64_flags | winreg.KEY_READ
                office_root = winreg.OpenKey(root, r"Software\Microsoft\Office", 0, flags)
            except WindowsError:
                continue

            # look for all installed versions of Excel and uninstall PyXLL
            i = 0
            while True:
                try:
                    subkey = winreg.EnumKey(office_root, i)
                except WindowsError:
                    break

                match = re.match("^(\d+(?:\.\d+)?)$", subkey)
                if match:
                    office_version = match.group(1)
                    uninstall(office_root, office_version, wow64_flags)
                i += 1

            winreg.CloseKey(office_root) 
开发者ID:pyxll,项目名称:pyxll-examples,代码行数:27,代码来源:uninstall.py

示例5: get_acroversion

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import EnumKey [as 别名]
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:
                    pass
    return None 
开发者ID:jgeisler0303,项目名称:CANFestivino,代码行数:18,代码来源:DS301_index.py

示例6: _get_labview_paths_windows

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import EnumKey [as 别名]
def _get_labview_paths_windows(self):
        # Connect to the registry at the root of the LabVIEW key
        import _winreg
        reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)

        installed_lv_paths = []
        # Iterate over all subkeys until you find one that isn't a version
        # number.  Each subkey represents a currently installed version of
        # LabVIEW. We want to pull from that the key indicating its install
        # path. We put each one into an array
        for root_key in [r"SOFTWARE\Wow6432Node\National Instruments\LabVIEW",
                         r"SOFTWARE\National Instruments\LabVIEW"]:
            try:
                key = self._open_windows_native_key(reg, root_key)
                i = 0
                current_lv_version = _winreg.EnumKey(key, i)
                while current_lv_version.find('.') != -1:
                    try:
                        current_lv_reg_key = self._open_windows_native_key(
                            reg, root_key + "\\" + current_lv_version)
                        value, key_type = _winreg.QueryValueEx(
                            current_lv_reg_key, "PATH")
                    except WindowsError as e:
                        if e.errno == 2:
                            pass
                    else:
                        installed_lv_paths.append(value)
                    finally:
                        i += 1
                        try:
                            current_lv_version = _winreg.EnumKey(key, i)
                        except (IOError, WindowsError):
                            break
            except WindowsError as e:
                # If the key doesn't exist LabVIEW may not be installed.  We
                # can safely ignore this error
                pass

        return installed_lv_paths 
开发者ID:ni,项目名称:python_labview_automation,代码行数:41,代码来源:labview.py

示例7: next

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import EnumKey [as 别名]
def next(self):
        try:
            k = _winreg.EnumKey(self.key.hkey,self.index)
        except WindowsError:
            raise StopIteration
        else:
            self.index += 1
            return Key(k,self.key) 
开发者ID:NVDARemote,项目名称:NVDARemote,代码行数:10,代码来源:regobj.py

示例8: get_tuntap_ComponentId

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import EnumKey [as 别名]
def get_tuntap_ComponentId():
    '''
    \brief Retrieve the instance ID of the TUN/TAP interface from the Windows
        registry,
    
    This function loops through all the sub-entries at the following location
    in the Windows registry: reg.HKEY_LOCAL_MACHINE, ADAPTER_KEY
      
    It looks for one which has the 'ComponentId' key set to
    TUNTAP_COMPONENT_ID, and returns the value of the 'NetCfgInstanceId' key.
    
    \return The 'ComponentId' associated with the TUN/TAP interface, a string
        of the form "{A9A413D7-4D1C-47BA-A3A9-92F091828881}".
    '''
    with reg.OpenKey(reg.HKEY_LOCAL_MACHINE, ADAPTER_KEY) as adapters:
        try:
            for i in xrange(10000):
                key_name = reg.EnumKey(adapters, i)
                with reg.OpenKey(adapters, key_name) as adapter:
                    try:
                        component_id = reg.QueryValueEx(adapter, 'ComponentId')[0]
                        if component_id == TUNTAP_COMPONENT_ID:
                            return reg.QueryValueEx(adapter, 'NetCfgInstanceId')[0]
                    except WindowsError, err:
                        pass
        except WindowsError, err:
            pass 
开发者ID:alexsunday,项目名称:pyvpn,代码行数:29,代码来源:tun-ping-responder.py

示例9: _enumerate_reg_keys

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import EnumKey [as 别名]
def _enumerate_reg_keys(key):
		return _RegKeyDict._enumerate_reg(key, _winreg.EnumKey) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:4,代码来源:win32timezone.py

示例10: list

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import EnumKey [as 别名]
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 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:11,代码来源:tzwin.py

示例11: __iter__

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import EnumKey [as 别名]
def __iter__(self):
        subkey_names = []
        try:
            with winreg.OpenKeyEx(self._root, self.subkey, 0, winreg.KEY_READ | self._flags) as key:
                for i in count():
                    subkey_names.append(winreg.EnumKey(key, i))
        except OSError:
            pass
        return iter(self[k] for k in subkey_names) 
开发者ID:sarugaku,项目名称:pythonfinder,代码行数:11,代码来源:_registry.py

示例12: _get_sid_from_registry

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import EnumKey [as 别名]
def _get_sid_from_registry():
    try:
        import winreg
    except ImportError:
        import _winreg as winreg
    var_names = ("%USERPROFILE%", "%HOME%")
    current_user_home = next(iter(os.path.expandvars(v) for v in var_names if v), None)
    root, subkey = (
        winreg.HKEY_LOCAL_MACHINE,
        r"Software\Microsoft\Windows NT\CurrentVersion\ProfileList",
    )
    subkey_names = []
    value = None
    matching_key = None
    try:
        with winreg.OpenKeyEx(root, subkey, 0, winreg.KEY_READ) as key:
            for i in count():
                key_name = winreg.EnumKey(key, i)
                subkey_names.append(key_name)
                value = query_registry_value(
                    root, r"{0}\{1}".format(subkey, key_name), "ProfileImagePath"
                )
                if value and value.lower() == current_user_home.lower():
                    matching_key = key_name
                    break
    except OSError:
        pass
    if matching_key is not None:
        return matching_key 
开发者ID:pypa,项目名称:pipenv,代码行数:31,代码来源:_winconsole.py

示例13: get_network_card_info

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import EnumKey [as 别名]
def get_network_card_info():
    reg = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
                          "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards")
    info = []
    for i in range(6):
        try:
            descp = _winreg.QueryValueEx(_winreg.OpenKeyEx(
                reg, _winreg.EnumKey(reg, i)), 'Description')[0]
            info.append(descp)
        except:
            break

    return info 
开发者ID:turingsec,项目名称:marsnake,代码行数:15,代码来源:overview_win.py

示例14: get_cpu_info

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import EnumKey [as 别名]
def get_cpu_info():
    reg = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor")
    flag = True
    model_name = ""
    num = _winreg.QueryInfoKey(reg)[0]
    reg2 = _winreg.OpenKeyEx(reg, _winreg.EnumKey(reg, 0))
    model_name = _winreg.QueryValueEx(reg2, 'ProcessorNameString')[0]

    return "{} *{}".format(model_name, num) 
开发者ID:turingsec,项目名称:marsnake,代码行数:11,代码来源:overview_win.py

示例15: listRegKeys

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import EnumKey [as 别名]
def listRegKeys(registry, key, architecture=None):
	import _winreg
	regKey = getRegKey(registry, key, architecture=architecture)
	ret = []
	if regKey:
		index = 0
		while True:
			try:
				ret.append(_winreg.EnumKey(regKey, index))
				index += 1
			except WindowsError:
				break
	return ret 
开发者ID:blurstudio,项目名称:cross3d,代码行数:15,代码来源:winregistry.py


注:本文中的_winreg.EnumKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。