當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。