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


Python winreg.KEY_ALL_ACCESS属性代码示例

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


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

示例1: set_windows_path_var

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

示例2: _delete_key_if_empty

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import KEY_ALL_ACCESS [as 别名]
def _delete_key_if_empty(self, service):
        key_name = self._key_for_service(service)
        key = winreg.OpenKey(
            winreg.HKEY_CURRENT_USER, key_name, 0, winreg.KEY_ALL_ACCESS
        )
        try:
            winreg.EnumValue(key, 0)
            return
        except WindowsError:
            pass
        winreg.CloseKey(key)

        # it's empty; delete everything
        while key_name != 'Software':
            parent, sep, base = key_name.rpartition('\\')
            key = winreg.OpenKey(
                winreg.HKEY_CURRENT_USER, parent, 0, winreg.KEY_ALL_ACCESS
            )
            winreg.DeleteKey(key, base)
            winreg.CloseKey(key)
            key_name = parent 
开发者ID:jaraco,项目名称:keyrings.alt,代码行数:23,代码来源:Windows.py

示例3: __init__

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import KEY_ALL_ACCESS [as 别名]
def __init__(self, args):
		self.listen = None
		for option in args.listen:
			protos = [x.name for x in option.protos]
			if option.unix or 'ssl' in protos or 'secure' in protos:
				continue
			if 'http' in protos:
				self.listen = option
				break
		if self.listen is None:
			print('No server listen on localhost by http')
		import winreg
		key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, self.KEY, 0, winreg.KEY_ALL_ACCESS)
		value, regtype = winreg.QueryValueEx(key, self.SUBKEY)
		assert regtype == winreg.REG_BINARY
		server = f'localhost:{self.listen.port}'.encode()
		bypass = '<local>'.encode()
		counter = int.from_bytes(value[4:8], 'little') + 1
		value = value[:4] + struct.pack('<III', counter, 3, len(server)) + server + struct.pack('<I', len(bypass)) + bypass + b'\x00'*36
		winreg.SetValueEx(key, self.SUBKEY, None, regtype, value)
		winreg.CloseKey(key) 
开发者ID:qwj,项目名称:python-proxy,代码行数:23,代码来源:sysproxy.py

示例4: set_doc_author_keys

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import KEY_ALL_ACCESS [as 别名]
def set_doc_author_keys(userinitials, username):
    try:
        with winreg.OpenKey(winreg.HKEY_CURRENT_USER, r'Software\Microsoft\Office\Common\UserInfo', 0,
                             winreg.KEY_ALL_ACCESS) as key:
            winreg.SetValueEx(key, "UserName", 0, winreg.REG_SZ, username)
            winreg.SetValueEx(key, "UserInitials", 0, winreg.REG_SZ, userinitials)
    except FileNotFoundError:
        print("[!] Office may not be installed and initially run to create the necessary key locations. "
              "Please install and open Office once to set it up.")
        raise FileNotFoundError

#  returns the list of playbook items to allow for the creation of the file, and if necessary, renaming it to the
#  desired extension
#
# set_save_format determines the file format
# set_save_extension will be the extension compatible with the type of file you're saving.
# docm format can't be named .doc when saved by word, but it will work if renamed afterward
#
# set_extension_after_save will indicate the file needs renamed after it is saved
# 
开发者ID:haroldogden,项目名称:adb,代码行数:22,代码来源:utils.py

示例5: set_envvar_in_registry

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import KEY_ALL_ACCESS [as 别名]
def set_envvar_in_registry(envvar, value):
    try:
        import winreg
    except ImportError:
        import _winreg as winreg

    reg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
    with winreg.OpenKey(reg, KEY, 0, winreg.KEY_ALL_ACCESS) as regkey:
        winreg.SetValueEx(regkey, envvar, 0, winreg.REG_EXPAND_SZ, value) 
开发者ID:coala,项目名称:coala-quickstart,代码行数:11,代码来源:store_env_in_registry.py

示例6: get_windows_path_var

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import KEY_ALL_ACCESS [as 别名]
def get_windows_path_var(self):
        with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as root:
            with winreg.OpenKey(root, "Environment", 0, winreg.KEY_ALL_ACCESS) as key:
                path, _ = winreg.QueryValueEx(key, "PATH")

                return path 
开发者ID:python-poetry,项目名称:poetry,代码行数:8,代码来源:get-poetry.py

示例7: checkstartup

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import KEY_ALL_ACCESS [as 别名]
def checkstartup():
    # check if it is linux
    if os_type in OS.UNIX_LIKE:
        # check if the startup exists
        if os.path.exists(home_address + "/.config/autostart/persepolis.desktop"):
            return True
        else:
            return False

    # check if it is mac
    elif os_type == OS.OSX:
        # OS X
        if os.path.exists(home_address + "/Library/LaunchAgents/com.persepolisdm.plist"):
            return True
        else:
            return False

    # check if it is Windows
    elif os_type == OS.WINDOWS:
        # try to open startup key and check persepolis value
        try:
            aKey = winreg.OpenKey(
                winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, winreg.KEY_ALL_ACCESS)
            startupvalue = winreg.QueryValueEx(aKey, 'persepolis')
            startup = True
        except WindowsError:
            startup = False

        # Close the connection
        winreg.CloseKey(aKey)

        # if the startup enabled or disabled
        if startup:
            return True
        if not startup:
            return False

# add startup file 
开发者ID:persepolisdm,项目名称:persepolis,代码行数:40,代码来源:startup.py

示例8: removestartup

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import KEY_ALL_ACCESS [as 别名]
def removestartup():
    # check if it is linux
    if os_type in OS.BSD_FAMILY:

        # remove it
        os.remove(home_address + "/.config/autostart/persepolis.desktop")

    # check if it is mac OS
    elif os_type == OS.OSX:
        # OS X
        if checkstartup():
            os.system('launchctl unload ' + home_address +
                      "/Library/LaunchAgents/com.persepolisdm.plist")
            os.remove(home_address +
                      "/Library/LaunchAgents/com.persepolisdm.plist")

    # check if it is Windows
    elif os_type == OS.WINDOWS:
        if checkstartup():
            # Connect to the startup path in Registry
            key = winreg.OpenKey(
                winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, winreg.KEY_ALL_ACCESS)

            # remove persepolis from startup
            winreg.DeleteValue(key, 'persepolis')

            # Close connection
            winreg.CloseKey(key) 
开发者ID:persepolisdm,项目名称:persepolis,代码行数:30,代码来源:startup.py

示例9: delete_password

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import KEY_ALL_ACCESS [as 别名]
def delete_password(self, service, username):
        """Delete the password for the username of the service.
        """
        try:
            key_name = self._key_for_service(service)
            hkey = winreg.OpenKey(
                winreg.HKEY_CURRENT_USER, key_name, 0, winreg.KEY_ALL_ACCESS
            )
            winreg.DeleteValue(hkey, username)
            winreg.CloseKey(hkey)
        except WindowsError:
            e = sys.exc_info()[1]
            raise PasswordDeleteError(e)
        self._delete_key_if_empty(service) 
开发者ID:jaraco,项目名称:keyrings.alt,代码行数:16,代码来源:Windows.py

示例10: setenv

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import KEY_ALL_ACCESS [as 别名]
def setenv(self, name, value):
        # Note: for 'system' scope, you must run this as Administrator
        key = winreg.OpenKey(self.root, self.subkey, 0, winreg.KEY_ALL_ACCESS)
        winreg.SetValueEx(key, name, 0, winreg.REG_EXPAND_SZ, value)
        winreg.CloseKey(key)
        # For some strange reason, calling SendMessage from the current process
        # doesn't propagate environment changes at all.
        # TODO: handle CalledProcessError (for assert)
        check_call('''\
"%s" -c "import win32api, win32con; assert win32api.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SETTINGCHANGE, 0, 'Environment')"''' % sys.executable) 
开发者ID:ActiveState,项目名称:code,代码行数:12,代码来源:recipe-577621.py

示例11: create_registry_entry

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import KEY_ALL_ACCESS [as 别名]
def create_registry_entry(product, arc_version):
    """Create a registry link back to the arcgisbinding package."""
    root_key = winreg.HKEY_CURRENT_USER
    if product == 'Pro':
        product_name = "ArcGISPro"
    else:
        product_name = "Desktop{}".format(arc_version)
    reg_path = "SOFTWARE\\Esri\\{}".format(product_name)

    package_key = 'RintegrationProPackagePath'
    link_key = None

    try:
        full_access = (winreg.KEY_WOW64_64KEY + winreg.KEY_ALL_ACCESS)
        # find the key, 64- or 32-bit we want it all
        link_key = winreg.OpenKey(root_key, reg_path, 0, full_access)
    except fnf_exception as error:
        handle_fnf(error)

    if link_key:
        try:
            arcpy.AddMessage("Using registry key to link install.")
            binding_path = "{}\\{}".format(r_lib_path(), "arcgisbinding")
            winreg.SetValueEx(link_key, package_key, 0,
                              winreg.REG_SZ, binding_path)
        except fnf_exception as error:
            handle_fnf(error) 
开发者ID:R-ArcGIS,项目名称:r-bridge-install,代码行数:29,代码来源:install_package.py

示例12: clear

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import KEY_ALL_ACCESS [as 别名]
def clear(self):
		if self.listen is None:
			return
		import winreg
		key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, self.KEY, 0, winreg.KEY_ALL_ACCESS)
		value, regtype = winreg.QueryValueEx(key, self.SUBKEY)
		assert regtype == winreg.REG_BINARY
		counter = int.from_bytes(value[4:8], 'little') + 1
		value = value[:4] + struct.pack('<II', counter, 1) + b'\x00'*44
		winreg.SetValueEx(key, self.SUBKEY, None, regtype, value)
		winreg.CloseKey(key) 
开发者ID:qwj,项目名称:python-proxy,代码行数:13,代码来源:sysproxy.py

示例13: set_startup

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import KEY_ALL_ACCESS [as 别名]
def set_startup():
    if plexpy.WIN_SYS_TRAY_ICON:
        plexpy.WIN_SYS_TRAY_ICON.change_tray_icons()

    startup_reg_path = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"

    exe = sys.executable
    if plexpy.FROZEN:
        args = [exe]
    else:
        args = [exe, plexpy.FULL_PATH]

    cmd = ' '.join(cmd_quote(arg) for arg in args).replace('python.exe', 'pythonw.exe').replace("'", '"')

    if plexpy.CONFIG.LAUNCH_STARTUP:
        try:
            winreg.CreateKey(winreg.HKEY_CURRENT_USER, startup_reg_path)
            registry_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, startup_reg_path, 0, winreg.KEY_WRITE)
            winreg.SetValueEx(registry_key, common.PRODUCT, 0, winreg.REG_SZ, cmd)
            winreg.CloseKey(registry_key)
            logger.info("Added Tautulli to Windows system startup registry key.")
            return True
        except WindowsError as e:
            logger.error("Failed to create Windows system startup registry key: %s", e)
            return False

    else:
        # Check if registry value exists
        try:
            registry_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, startup_reg_path, 0, winreg.KEY_ALL_ACCESS)
            winreg.QueryValueEx(registry_key, common.PRODUCT)
            reg_value_exists = True
        except WindowsError:
            reg_value_exists = False

        if reg_value_exists:
            try:
                winreg.DeleteValue(registry_key, common.PRODUCT)
                winreg.CloseKey(registry_key)
                logger.info("Removed Tautulli from Windows system startup registry key.")
                return True
            except WindowsError as e:
                logger.error("Failed to delete Windows system startup registry key: %s", e)
                return False 
开发者ID:Tautulli,项目名称:Tautulli,代码行数:46,代码来源:windows.py


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