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


Python _winreg.HKEY_CURRENT_USER属性代码示例

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


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

示例1: _get_win_folder_from_registry

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

示例2: _get_win_folder_from_registry

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

示例3: _get_win_folder_from_registry

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

示例4: set_windows_path_var

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import HKEY_CURRENT_USER [as 别名]
def set_windows_path_var(self, value):
        import ctypes

        with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as root:
            with winreg.OpenKey(root, "Environment", 0, winreg.KEY_ALL_ACCESS) as key:
                winreg.SetValueEx(key, "PATH", 0, winreg.REG_EXPAND_SZ, value)

        # Tell other processes to update their environment
        HWND_BROADCAST = 0xFFFF
        WM_SETTINGCHANGE = 0x1A

        SMTO_ABORTIFHUNG = 0x0002

        result = ctypes.c_long()
        SendMessageTimeoutW = ctypes.windll.user32.SendMessageTimeoutW
        SendMessageTimeoutW(
            HWND_BROADCAST,
            WM_SETTINGCHANGE,
            0,
            u"Environment",
            SMTO_ABORTIFHUNG,
            5000,
            ctypes.byref(result),
        ) 
开发者ID:python-poetry,项目名称:poetry,代码行数:26,代码来源:get-poetry.py

示例5: _get_win_folder_from_registry

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

示例6: test_reg_class

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import HKEY_CURRENT_USER [as 别名]
def test_reg_class(self):
        from distutils.msvc9compiler import Reg
        self.assertRaises(KeyError, Reg.get_value, 'xxx', 'xxx')

        # looking for values that should exist on all
        # windows registry versions.
        path = r'Control Panel\Desktop'
        v = Reg.get_value(path, u'dragfullwindows')
        self.assertIn(v, (u'0', u'1', u'2'))

        import _winreg
        HKCU = _winreg.HKEY_CURRENT_USER
        keys = Reg.read_keys(HKCU, 'xxxx')
        self.assertEqual(keys, None)

        keys = Reg.read_keys(HKCU, r'Control Panel')
        self.assertIn('Desktop', keys) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_msvc9compiler.py

示例7: test_reg_class

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import HKEY_CURRENT_USER [as 别名]
def test_reg_class(self):
        from distutils.msvc9compiler import Reg
        self.assertRaises(KeyError, Reg.get_value, 'xxx', 'xxx')

        # looking for values that should exist on all
        # windows registeries versions.
        path = r'Control Panel\Desktop'
        v = Reg.get_value(path, u'dragfullwindows')
        self.assertTrue(v in (u'0', u'1', u'2'))

        import _winreg
        HKCU = _winreg.HKEY_CURRENT_USER
        keys = Reg.read_keys(HKCU, 'xxxx')
        self.assertEqual(keys, None)

        keys = Reg.read_keys(HKCU, r'Control Panel')
        self.assertTrue('Desktop' in keys) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:test_msvc9compiler.py

示例8: test_reg_class

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import HKEY_CURRENT_USER [as 别名]
def test_reg_class(self):
        from distutils.msvc9compiler import Reg
        self.assertRaises(KeyError, Reg.get_value, 'xxx', 'xxx')

        # looking for values that should exist on all
        # windows registeries versions.
        path = r'Control Panel\Desktop'
        v = Reg.get_value(path, u'dragfullwindows')
        self.assertIn(v, (u'0', u'1', u'2'))

        import _winreg
        HKCU = _winreg.HKEY_CURRENT_USER
        keys = Reg.read_keys(HKCU, 'xxxx')
        self.assertEqual(keys, None)

        keys = Reg.read_keys(HKCU, r'Control Panel')
        self.assertIn('Desktop', keys) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:19,代码来源:test_msvc9compiler.py

示例9: _get_win_folder_from_registry

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import HKEY_CURRENT_USER [as 别名]
def _get_win_folder_from_registry(csidl_name):
    # type: (str) -> str
    """
    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:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:23,代码来源:appdirs.py


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