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


Python _winreg.QueryValueEx方法代码示例

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


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

示例1: WIN_get_device_guid

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

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryValueEx [as 别名]
def getPathFromRegistry():
    registryPath = r"Software\Microsoft\Windows\CurrentVersion\App Paths\trelby.exe"

    try:
        import _winreg

        regPathKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, registryPath)
        regPathValue, regPathType = _winreg.QueryValueEx(regPathKey, "Path")

        if regPathType == _winreg.REG_SZ:
            return regPathValue
        else:
            raise TypeError

    except:
        wx.MessageBox("There was an error reading the following registry key: %s.\n"
                      "You may need to reinstall the program to fix this error." %
                      registryPath, "Error", wx.OK)
        sys.exit()

# convert s, which is returned from the wxWidgets GUI and is an Unicode
# string, to a normal string. 
开发者ID:trelby,项目名称:trelby,代码行数:24,代码来源:misc.py

示例3: _get_win_folder_from_registry

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryValueEx [as 别名]
def _get_win_folder_from_registry(csidl_name):
    """This is a fallback technique at best. I'm not sure if using the
    registry for this guarantees us the correct answer for all CSIDL_*
    names.
    """
    import _winreg

    shell_folder_name = {
        "CSIDL_APPDATA": "AppData",
        "CSIDL_COMMON_APPDATA": "Common AppData",
        "CSIDL_LOCAL_APPDATA": "Local AppData",
    }[csidl_name]

    key = _winreg.OpenKey(
        _winreg.HKEY_CURRENT_USER,
        r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
    )
    dir, type = _winreg.QueryValueEx(key, shell_folder_name)
    return dir 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:appdirs.py

示例4: _get_win_folder_from_registry

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryValueEx [as 别名]
def _get_win_folder_from_registry(csidl_name):
    """
    This is a fallback technique at best. I'm not sure if using the
    registry for this guarantees us the correct answer for all CSIDL_*
    names.
    """
    import _winreg

    shell_folder_name = {
        "CSIDL_APPDATA": "AppData",
        "CSIDL_COMMON_APPDATA": "Common AppData",
        "CSIDL_LOCAL_APPDATA": "Local AppData",
    }[csidl_name]

    key = _winreg.OpenKey(
        _winreg.HKEY_CURRENT_USER,
        r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
    )
    directory, _type = _winreg.QueryValueEx(key, shell_folder_name)
    return directory 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:22,代码来源:appdirs.py

示例5: _win32_getvalue

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryValueEx [as 别名]
def _win32_getvalue(key,name,default=''):

    """ Read a value for name from the registry key.

        In case this fails, default is returned.

    """
    try:
        # Use win32api if available
        from win32api import RegQueryValueEx
    except ImportError:
        # On Python 2.0 and later, emulate using _winreg
        import _winreg
        RegQueryValueEx = _winreg.QueryValueEx
    try:
        return RegQueryValueEx(key,name)
    except:
        return default 
开发者ID:glmcdona,项目名称:meddle,代码行数:20,代码来源:platform.py

示例6: _get_win_folder_from_registry

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryValueEx [as 别名]
def _get_win_folder_from_registry(csidl_name):
    """This is a fallback technique at best. I'm not sure if using the
    registry for this guarantees us the correct answer for all CSIDL_*
    names.
    """
    if PY3:
      import winreg as _winreg
    else:
      import _winreg

    shell_folder_name = {
        "CSIDL_APPDATA": "AppData",
        "CSIDL_COMMON_APPDATA": "Common AppData",
        "CSIDL_LOCAL_APPDATA": "Local AppData",
    }[csidl_name]

    key = _winreg.OpenKey(
        _winreg.HKEY_CURRENT_USER,
        r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
    )
    dir, type = _winreg.QueryValueEx(key, shell_folder_name)
    return dir 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:24,代码来源:appdirs.py

示例7: _get_win_folder_from_registry

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryValueEx [as 别名]
def _get_win_folder_from_registry(csidl_name):
    """
    This is a fallback technique at best. I'm not sure if using the
    registry for this guarantees us the correct answer for all CSIDL_*
    names.
    """
    import _winreg

    shell_folder_name = {
        "CSIDL_APPDATA": "AppData",
        "CSIDL_COMMON_APPDATA": "Common AppData",
        "CSIDL_LOCAL_APPDATA": "Local AppData",
    }[csidl_name]

    key = _winreg.OpenKey(
        _winreg.HKEY_CURRENT_USER,
        r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders",
    )
    directory, _type = _winreg.QueryValueEx(key, shell_folder_name)
    return directory 
开发者ID:python-poetry,项目名称:poetry,代码行数:22,代码来源:appdirs.py

示例8: get_device_guid

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

示例9: teardown_environment

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryValueEx [as 别名]
def teardown_environment():
    """Restore things that were remembered by the setup_environment function
    """
    (oldenv, os.name, sys.platform, path.get_home_dir, IPython.__file__, old_wd) = oldstuff
    os.chdir(old_wd)
    reload(path)

    for key in env.keys():
        if key not in oldenv:
            del env[key]
    env.update(oldenv)
    if hasattr(sys, 'frozen'):
        del sys.frozen
    if os.name == 'nt':
        (wreg.OpenKey, wreg.QueryValueEx,) = platformstuff

# Build decorator that uses the setup_environment/setup_environment 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:test_path.py

示例10: test_get_home_dir_8

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import QueryValueEx [as 别名]
def test_get_home_dir_8():
    """Using registry hack for 'My Documents', os=='nt'

    HOMESHARE, HOMEDRIVE, HOMEPATH, USERPROFILE and others are missing.
    """
    os.name = 'nt'
    # Remove from stub environment all keys that may be set
    for key in ['HOME', 'HOMESHARE', 'HOMEDRIVE', 'HOMEPATH', 'USERPROFILE']:
        env.pop(key, None)

    #Stub windows registry functions
    def OpenKey(x, y):
        class key:
            def Close(self):
                pass
        return key()
    def QueryValueEx(x, y):
        return [abspath(HOME_TEST_DIR)]

    wreg.OpenKey = OpenKey
    wreg.QueryValueEx = QueryValueEx

    home_dir = path.get_home_dir()
    nt.assert_equal(home_dir, abspath(HOME_TEST_DIR)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:26,代码来源:test_path.py

示例11: _get_labview_paths_windows

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


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