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


Python winreg.DeleteValue方法代码示例

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


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

示例1: toggle_run_on_startup

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import DeleteValue [as 别名]
def toggle_run_on_startup(self, is_checked):
        if (self.platform == 'Windows'):
            key = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
                                 r'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run',
                                 0, winreg.KEY_SET_VALUE)

            if (is_checked):
                path = sys.executable
                winreg.SetValueEx(key, 'Blender Version Manager',
                                  0, winreg.REG_SZ, path)
            else:
                try:
                    winreg.DeleteValue(key, 'Blender Version Manager')
                except:
                    pass

            key.Close()
            self.settings.setValue('is_run_on_startup', is_checked) 
开发者ID:DotBow,项目名称:Blender-Version-Manager,代码行数:20,代码来源:main_window.py

示例2: path_cleanup

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import DeleteValue [as 别名]
def path_cleanup():
    ''' Removes SIMNIBS from PATH '''
    if sys.platform in ['linux', 'darwin']:
        bashrc, backup_file = _get_bashrc()

        if not os.path.isfile(bashrc):
            print('Could not find bashrc file')
            return

        print('Removing SimNIBS install from PATH')
        print(f'Backing up the bashrc file at {backup_file}')
        _copy_and_log(bashrc, backup_file)
        with open(backup_file, 'r') as fin:
            with open(bashrc, 'w') as fout:
                for line in fin:
                    if not re.search('simnibs', line, re.IGNORECASE):
                        fout.write(line)
    else:
        simnibs_env_vars = _get_win_simnibs_env_vars()
        path = _get_win_path()
        path = path.split(';')
        path = [p for p in path if len(p) > 0]
        for key, value in simnibs_env_vars.items():
            # If the directory is in the PATH variable, remove it
            path = [
                os.path.normpath(p) for p in path if not (
                os.path.normpath(value) in os.path.normpath(p))]
            # Remove environment variable
            with winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Environment', access=winreg.KEY_WRITE) as reg:
                winreg.DeleteValue(reg, key)

        # write out the PATH with SimNIBS removed
        with winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Environment', access=winreg.KEY_WRITE) as reg:
            path = ';'.join(path) + ';'
            winreg.SetValueEx(reg,'Path', 0, winreg.REG_EXPAND_SZ, path) 
开发者ID:simnibs,项目名称:simnibs,代码行数:37,代码来源:postinstall_simnibs.py

示例3: __delitem__

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import DeleteValue [as 别名]
def __delitem__(self,name):
        """Item deletion deletes key values."""
        self.sam |= KEY_SET_VALUE
        try:
            _winreg.DeleteValue(self.hkey,name)
        except WindowsError:
            raise KeyError("no such value: '%s'" % (name,)) 
开发者ID:NVDARemote,项目名称:NVDARemote,代码行数:9,代码来源:regobj.py

示例4: uninstall

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import DeleteValue [as 别名]
def uninstall():
    if check_installed() is True:
        runkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
            r"Software\Microsoft\Windows\CurrentVersion\Run", 0,
            winreg.KEY_WRITE)
        winreg.DeleteValue(runkey, "Px")
        winreg.CloseKey(runkey)
        pprint("Px uninstalled successfully")
    else:
        pprint("Px is not installed")

    sys.exit()

###
# Attach/detach console 
开发者ID:genotrance,项目名称:px,代码行数:17,代码来源:px.py

示例5: removestartup

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

示例6: delete_password

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

示例7: set_value

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import DeleteValue [as 别名]
def set_value(self, value_name, value):
        with winreg.CreateKeyEx(self._root, self.subkey, 0, winreg.KEY_WRITE | self._flags) as key:
            if value is None:
                winreg.DeleteValue(key, value_name)
            elif isinstance(value, str):
                winreg.SetValueEx(key, value_name, 0, winreg.REG_SZ, value)
            else:
                raise TypeError('cannot write {} to registry'.format(type(value))) 
开发者ID:sarugaku,项目名称:pythonfinder,代码行数:10,代码来源:_registry.py

示例8: _set_all_values

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import DeleteValue [as 别名]
def _set_all_values(self, rootkey, name, info, errors):
        with winreg.CreateKeyEx(rootkey, name, 0, winreg.KEY_WRITE | self._flags) as key:
            for k, v in info:
                if isinstance(v, PythonWrappedDict):
                    self._set_all_values(key, k, v._items(), errors)
                elif isinstance(v, dict):
                    self._set_all_values(key, k, v.items(), errors)
                elif v is None:
                    winreg.DeleteValue(key, k)
                elif isinstance(v, str):
                    winreg.SetValueEx(key, k, 0, winreg.REG_SZ, v)
                else:
                    errors.append('cannot write {} to registry'.format(type(v))) 
开发者ID:sarugaku,项目名称:pythonfinder,代码行数:15,代码来源:_registry.py

示例9: del_value

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import DeleteValue [as 别名]
def del_value(self, key, value=''):
        if self.no_restore is False:
            try:
                return winreg.DeleteValue(key, value)
            except WindowsError as error:
                return None 
开发者ID:ElevenPaths,项目名称:uac-a-mola,代码行数:8,代码来源:ext_server_uacamola.py

示例10: __remove_from_startup_programs

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import DeleteValue [as 别名]
def __remove_from_startup_programs(self):
        '''
        @summary: Removes Crypter from the list of startup programs
        @todo: Code and test
        '''

        try:
            reg = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER, self.STARTUP_REGISTRY_LOCATION, 0, winreg.KEY_SET_VALUE)
            winreg.DeleteValue(reg, "Crypter")
            winreg.CloseKey(reg)
        except WindowsError:
            pass 
开发者ID:sithis993,项目名称:Crypter,代码行数:14,代码来源:Crypter.py

示例11: set_startup

# 需要导入模块: import winreg [as 别名]
# 或者: from winreg import DeleteValue [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.DeleteValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。