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


Python winreg.QueryValueEx方法代码示例

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


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

示例1: _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:war-and-code,项目名称:jawfish,代码行数:20,代码来源:platform.py

示例2: _get_windows_python_path

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import QueryValueEx [as 别名]
def _get_windows_python_path(x64):
    """Get the path to Python.exe on Windows."""
    parts = str(sys.version_info.major), str(sys.version_info.minor)
    ver = ''.join(parts)
    dot_ver = '.'.join(parts)

    if x64:
        path = (r'SOFTWARE\Python\PythonCore\{}\InstallPath'
                .format(dot_ver))
        fallback = r'C:\Python{}\python.exe'.format(ver)
    else:
        path = (r'SOFTWARE\WOW6432Node\Python\PythonCore\{}-32\InstallPath'
                .format(dot_ver))
        fallback = r'C:\Python{}-32\python.exe'.format(ver)

    try:
        key = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, path)
        return winreg.QueryValueEx(key, 'ExecutablePath')[0]
    except FileNotFoundError:
        return fallback 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:22,代码来源:build_release.py

示例3: is_using_dcs_steam_edition

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import QueryValueEx [as 别名]
def is_using_dcs_steam_edition():
    """
    Check if DCS World : Steam Edition version is installed on this computer
    :return True if DCS Steam edition is installed,
            -1 if DCS Steam Edition is registered in Steam apps but not installed,
            False if never installed in Steam
    """
    if not is_windows_os:
        return False
    try:
        # Note : Steam App ID for DCS World is 223750
        dcs_steam_app_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, "Software\\Valve\\Steam\\Apps\\223750")
        installed = winreg.QueryValueEx(dcs_steam_app_key, "Installed")
        winreg.CloseKey(dcs_steam_app_key)
        if installed[0] == 1:
            return True
        else:
            return False
    except FileNotFoundError as fnfe:
        return False 
开发者ID:pydcs,项目名称:dcs,代码行数:22,代码来源:installation.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.
    """
    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

示例5: windows_group_policy_path

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import QueryValueEx [as 别名]
def windows_group_policy_path():
    # we know that we're running under windows at this point so it's safe to do these imports
    from winreg import ConnectRegistry, HKEY_LOCAL_MACHINE, OpenKeyEx, QueryValueEx, REG_EXPAND_SZ, REG_SZ
    try:
        root = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
        policy_key = OpenKeyEx(root, r"SOFTWARE\Policies\Google\Chrome")
        user_data_dir, type_ = QueryValueEx(policy_key, "UserDataDir")
        if type_ == REG_EXPAND_SZ:
            user_data_dir = os.path.expandvars(user_data_dir)
        elif type_ != REG_SZ:
            return None
    except OSError:
        return None
    return os.path.join(user_data_dir, "Default", "Cookies")


# Code adapted slightly from https://github.com/Arnie97/chrome-cookies 
开发者ID:borisbabic,项目名称:browser_cookie3,代码行数:19,代码来源:__init__.py

示例6: default_cm3d2_dir

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import QueryValueEx [as 别名]
def default_cm3d2_dir(base_dir, file_name, new_ext):
	if not base_dir:
		if preferences().cm3d2_path:
			base_dir = os.path.join(preferences().cm3d2_path, "GameData", "*." + new_ext)
		else:
			try:
				import winreg
				with winreg.OpenKey(winreg.HKEY_CURRENT_USER, r'Software\KISS\カスタムメイド3D2') as key:
					base_dir = winreg.QueryValueEx(key, 'InstallPath')[0]
					preferences().cm3d2_path = base_dir
					base_dir = os.path.join(base_dir, "GameData", "*." + new_ext)
			except: pass
	if file_name:
		base_dir = os.path.join(os.path.split(base_dir)[0], file_name)
	base_dir = os.path.splitext(base_dir)[0] + "." + new_ext
	return base_dir

# 一時ファイル書き込みと自動バックアップを行うファイルオブジェクトを返す 
开发者ID:CM3D2user,项目名称:Blender-CM3D2-Converter,代码行数:20,代码来源:common.py

示例7: get_home_dir

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import QueryValueEx [as 别名]
def get_home_dir(self, username):
            """Return the user's profile directory, the closest thing
            to a user home directory we have on Windows.
            """
            try:
                sid = win32security.ConvertSidToStringSid(
                    win32security.LookupAccountName(None, username)[0])
            except pywintypes.error as err:
                raise AuthorizerError(err)
            path = r"SOFTWARE\Microsoft\Windows NT" \
                   r"\CurrentVersion\ProfileList" + "\\" + sid
            try:
                key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path)
            except WindowsError:
                raise AuthorizerError(
                    "No profile directory defined for user %s" % username)
            value = winreg.QueryValueEx(key, "ProfileImagePath")[0]
            home = win32api.ExpandEnvironmentStrings(value)
            if not PY3 and not isinstance(home, unicode):
                home = home.decode('utf8')
            return home 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:23,代码来源:authorizers.py

示例8: get_password

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import QueryValueEx [as 别名]
def get_password(self, service, username):
        """Get password of the username for the service
        """
        try:
            # fetch the password
            key = self._key_for_service(service)
            hkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, key)
            password_saved = winreg.QueryValueEx(hkey, username)[0]
            password_base64 = password_saved.encode('ascii')
            # decode with base64
            password_encrypted = base64.decodestring(password_base64)
            # decrypted the password
            password = _win_crypto.decrypt(password_encrypted).decode('utf-8')
        except EnvironmentError:
            password = None
        return password 
开发者ID:jaraco,项目名称:keyrings.alt,代码行数:18,代码来源:Windows.py

示例9: proxy_bypass_registry

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import QueryValueEx [as 别名]
def proxy_bypass_registry(host):
        try:
            if is_py3:
                import winreg
            else:
                import _winreg as winreg
        except ImportError:
            return False

        try:
            internetSettings = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
                r'Software\Microsoft\Windows\CurrentVersion\Internet Settings')
            # ProxyEnable could be REG_SZ or REG_DWORD, normalizing it
            proxyEnable = int(winreg.QueryValueEx(internetSettings,
                                              'ProxyEnable')[0])
            # ProxyOverride is almost always a string
            proxyOverride = winreg.QueryValueEx(internetSettings,
                                                'ProxyOverride')[0]
        except OSError:
            return False
        if not proxyEnable or not proxyOverride:
            return False

        # make a check value list from the registry entry: replace the
        # '<local>' string by the localhost entry and the corresponding
        # canonical entry.
        proxyOverride = proxyOverride.split(';')
        # now check if we match one of the registry values.
        for test in proxyOverride:
            if test == '<local>':
                if '.' not in host:
                    return True
            test = test.replace(".", r"\.")     # mask dots
            test = test.replace("*", r".*")     # change glob sequence
            test = test.replace("?", r".")      # change glob char
            if re.match(test, host, re.I):
                return True
        return False 
开发者ID:danielecook,项目名称:gist-alfred,代码行数:40,代码来源:utils.py

示例10: _get_win_path

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import QueryValueEx [as 别名]
def _get_win_path():
    with winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Environment') as reg:
        try:
            path = winreg.QueryValueEx(reg, 'Path')[0]
        except FileNotFoundError: # PATH not set
            path = ''
    return path 
开发者ID:simnibs,项目名称:simnibs,代码行数:9,代码来源:postinstall_simnibs.py

示例11: proxy_bypass_registry

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import QueryValueEx [as 别名]
def proxy_bypass_registry(host):
        if is_py3:
            import winreg
        else:
            import _winreg as winreg
        try:
            internetSettings = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
                r'Software\Microsoft\Windows\CurrentVersion\Internet Settings')
            proxyEnable = winreg.QueryValueEx(internetSettings,
                                              'ProxyEnable')[0]
            proxyOverride = winreg.QueryValueEx(internetSettings,
                                                'ProxyOverride')[0]
        except OSError:
            return False
        if not proxyEnable or not proxyOverride:
            return False

        # make a check value list from the registry entry: replace the
        # '<local>' string by the localhost entry and the corresponding
        # canonical entry.
        proxyOverride = proxyOverride.split(';')
        # now check if we match one of the registry values.
        for test in proxyOverride:
            if test == '<local>':
                if '.' not in host:
                    return True
            test = test.replace(".", r"\.")     # mask dots
            test = test.replace("*", r".*")     # change glob sequence
            test = test.replace("?", r".")      # change glob char
            if re.match(test, host, re.I):
                return True
        return False 
开发者ID:getavalon,项目名称:core,代码行数:34,代码来源:utils.py


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