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


Python _winreg.QueryInfoKey方法代码示例

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


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

示例1: win32_reg_read

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryInfoKey [as 别名]
def win32_reg_read (self, keyname, path):
		try:
			import _winreg
			mode = _winreg.KEY_READ | _winreg.KEY_WOW64_64KEY
			key = _winreg.OpenKey(keyname, path, 0, mode)
			count = _winreg.QueryInfoKey(key)[0]
		except:
			return None
		data = {}
		for i in range(count):
			try:
				name, value, tt = _winreg.EnumValue(key, i)
			except OSError as e:
				break
			data[name] = (tt, value) 
		return data 
开发者ID:skywind3000,项目名称:terminal,代码行数:18,代码来源:terminal.py

示例2: listRegKeyValues

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryInfoKey [as 别名]
def listRegKeyValues(registry, key, architecture=None):
	""" Returns a list of child keys and their values as tuples.
	
	Each tuple contains 3 items.
		- A string that identifies the value name
		- An object that holds the value data, and whose type depends on the underlying registry type
		- An integer that identifies the type of the value data (see table in docs for _winreg.SetValueEx)
	
	Args:
		registry (str): The registry to look in. 'HKEY_LOCAL_MACHINE' for example
		key (str): The key to open. r'Software\Autodesk\Softimage\InstallPaths' for example
		architecture (int | None): 32 or 64 bit. If None use system default. Defaults to None
	
	Returns:
		List of tuples
	"""
	import _winreg
	regKey = getRegKey(registry, key, architecture=architecture)
	ret = []
	if regKey:
		subKeys, valueCount, modified = _winreg.QueryInfoKey(regKey)
		for index in range(valueCount):
			ret.append(_winreg.EnumValue(regKey, index))
	return ret 
开发者ID:blurstudio,项目名称:cross3d,代码行数:26,代码来源:winregistry.py

示例3: __init__

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryInfoKey [as 别名]
def __init__(self):
        self.hkey={}
        for key in (k for k in dir(reg) if k.startswith('HKEY_')):
            try:
                chk = reg.ConnectRegistry(None, getattr(reg, key))
                inf = reg.QueryInfoKey(chk)
                reg.CloseKey(chk)
            except WindowsError: pass           # some keys may appear in _winreg but can't be reached
            else:
                hk = Hkey(key)
                try:
                    chk=hk.keys
                except WindowsError: pass       # some keys can be accessed but not enumerated
                else:                           # some keys work fine ...
                    name=key[5:].lower()
                    self.hkey[name]=hk          # for iterating
                    setattr(self, name, hk)     # for easy access 
开发者ID:ActiveState,项目名称:code,代码行数:19,代码来源:recipe-502268.py

示例4: get_reboot_required

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryInfoKey [as 别名]
def get_reboot_required():
  """Returns True if the system should be rebooted to apply updates.

  This is not guaranteed to notice all conditions that could require reboot.
  """
  # Based on https://stackoverflow.com/a/45717438
  k = None
  import _winreg
  try:
    k = _winreg.OpenKey(
        _winreg.HKEY_LOCAL_MACHINE,
        'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\'
        'Auto Update\\RebootRequired')
    _, num_values, _ = _winreg.QueryInfoKey(k)
    return num_values > 0
  except WindowsError:  # pylint: disable=undefined-variable
    # This error very likely means the RebootRequired key does not exist,
    # meaning reboot is not required.
    return False
  finally:
    if k:
      k.Close() 
开发者ID:luci,项目名称:luci-py,代码行数:24,代码来源:win.py

示例5: get_acroversion

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryInfoKey [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: __len__

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryInfoKey [as 别名]
def __len__(self):
        """len() gives the number of values and subkeys."""
        info = _winreg.QueryInfoKey(self.hkey)
        return info[0] + info[1] 
开发者ID:NVDARemote,项目名称:NVDARemote,代码行数:6,代码来源:regobj.py

示例7: valuestodict

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

示例8: list

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryInfoKey [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

示例9: valuestodict

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

示例10: get_cpu_info

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryInfoKey [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

示例11: keys

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryInfoKey [as 别名]
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 
开发者ID:ActiveState,项目名称:code,代码行数:12,代码来源:recipe-502268.py

示例12: vals

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

示例13: __len__

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryInfoKey [as 别名]
def __len__(self):
        "value is approximate since .keys() drops non-string types"
        with _winreg.OpenKey(self._hive, self._key) as k:
            num_subkeys, num_values, t = _winreg.QueryInfoKey(k)
            return num_values 
开发者ID:ActiveState,项目名称:code,代码行数:7,代码来源:recipe-577381.py

示例14: _user_sids

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryInfoKey [as 别名]
def _user_sids():
    """Map between usernames and the related SID."""
    user_sids = {}

    root_key = winreg.HKEY_LOCAL_MACHINE
    reg_path = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList"

    try:
        log.info("OpenKey on {}, with READ + WOW64".format(reg_path))
        sid_reg = winreg.OpenKey(root_key, reg_path,
                                 0, READ_ACCESS)

    except fnf_exception as error:
        handle_fnf(error)

    if sid_reg:
        subkey_count = winreg.QueryInfoKey(sid_reg)[0]
        for pos in range(subkey_count):
            try:
                sid = winreg.EnumKey(sid_reg, pos)
            except:
                pass
            if sid:
                profile_path_key = "{}\\{}".format(reg_path, sid)
                try:
                    profile_path_reg = winreg.OpenKey(
                        root_key, profile_path_key, 0, READ_ACCESS)

                    profile_path = winreg.QueryValueEx(
                        profile_path_reg, "ProfileImagePath")[0]

                    username = profile_path.split("\\")[-1]
                    user_sids[username] = sid
                except:
                    pass

    return user_sids 
开发者ID:R-ArcGIS,项目名称:r-bridge-install,代码行数:39,代码来源:rpath.py

示例15: get_visual_studio_versions

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryInfoKey [as 别名]
def get_visual_studio_versions():
  """Retrieves all installed Visual Studio versions.

  The returned version list is sorted such that the first element is the highest
  version number.

  Returns:
    A list of Visual Studio version strings.
  """
  import _winreg

  try:
    k = _winreg.OpenKey(
        _winreg.HKEY_LOCAL_MACHINE,
        'SOFTWARE\\Wow6432Node\\Microsoft\\VSCommon')
  # pylint: disable=undefined-variable
  except WindowsError:
    return None

  try:
    versions = []
    for i in range(_winreg.QueryInfoKey(k)[0]):
      sub_key = _winreg.EnumKey(k, i)
      if re.match(r'\d+\.\d+', sub_key):
        versions.append(sub_key)
    return sorted(versions, key=float, reverse=True)
  finally:
    k.Close() 
开发者ID:luci,项目名称:luci-py,代码行数:30,代码来源:win.py


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