Python winreg 模块,DeleteValue() 实例源码

我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用winreg.DeleteValue()

项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def unregister(classobj):
    import winreg
    subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" % classobj._reg_clsid_
    try:
        hKey = winreg.CreateKey( winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
        subKey = winreg.DeleteValue( hKey, "ButtonText" )
        winreg.DeleteValue( hKey, "ClsidExtension" ) # for calling COM object
        winreg.DeleteValue( hKey, "CLSID" )
        winreg.DeleteValue( hKey, "Default Visible" )
        winreg.DeleteValue( hKey, "ToolTip" )
        winreg.DeleteValue( hKey, "Icon" )
        winreg.DeleteValue( hKey, "HotIcon" )
        winreg.DeleteKey( winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
    except WindowsError:
        print("Couldn't delete Standard toolbar regkey.")
    else:
        print("Deleted Standard toolbar regkey.")

#
# test implementation
#
项目:paste2box    作者:rokups    | 项目源码 | 文件源码
def is_autostart_enabled(self):
        if os.name == 'nt':
            with winreg.OpenKey(winreg.HKEY_CURRENT_USER, self._windows_run_reg_key, 0, winreg.KEY_ALL_ACCESS) as key:
                try:
                    reg_value, reg_type = winreg.QueryValueEx(key, const.APP_NAME)
                    if reg_type == winreg.REG_SZ and reg_value == self._get_executable_path():
                        return True
                    else:
                        try:
                            winreg.DeleteValue(key, self.WIN_REG_AUTORUN_KEY)
                        except OSError:
                            pass        # key does not exist
                except:
                    return False
        else:
            return os.path.exists(self._linux_autostart_file)
项目:paste2box    作者:rokups    | 项目源码 | 文件源码
def _save_autostart_win(self, on):
        with winreg.OpenKey(winreg.HKEY_CURRENT_USER, self._windows_run_reg_key, 0, winreg.KEY_ALL_ACCESS) as key:
            if on:
                winreg.SetValueEx(key, const.APP_NAME, 0, winreg.REG_SZ, self._get_executable_path())
            else:
                try:
                    winreg.DeleteValue(key, const.APP_NAME)
                except OSError:
                    pass        # key does not exist
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def DllUnregisterServer():
    comclass = IEToolbar

    # unregister toolbar from internet explorer
    try:
        print("Trying to unregister Toolbar.\n")
        hkey = winreg.CreateKey( winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Toolbar" )
        winreg.DeleteValue( hkey, comclass._reg_clsid_ )
    except WindowsError:
        print("Couldn't delete registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ ))
    else:
        print("Deleting reg key succeeded.\n")

# entry point
项目:SDV-Summary    作者:Sketchy502    | 项目源码 | 文件源码
def remove_from_startup():
    try:
        key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 0, winreg.KEY_SET_VALUE)
        winreg.DeleteValue(key, REGISTRY_NAME)
        key.Close()
    except:
        pass
项目:keypirinha-plugins    作者:EhsanKia    | 项目源码 | 文件源码
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,))
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def remmoveEnvironment(scope, name):
    assert scope in ('user', 'system')

    if platform.system() == 'Windows':
        root, subkey = getWindowsEnvironmentKey(scope)
        key = winreg.OpenKey(root, subkey, 0, winreg.KEY_ALL_ACCESS)

        try:
            winreg.DeleteValue(key, name)
        except WindowsError:
            pass
    else:
        removeLinuxEnvironment(scope, name)
项目:GotoX    作者:SeaHOH    | 项目源码 | 文件源码
def on_disable_proxy(systray):
    proxy_state = proxy_state_menu
    if proxy_state.type & 1:
        winreg.DeleteValue(SETTINGS, 'AutoConfigURL')
    if proxy_state.type & 2:
        winreg.SetValueEx(SETTINGS, 'ProxyEnable', 0,  winreg.REG_DWORD, 0)
    refresh_proxy_state()
项目:GotoX    作者:SeaHOH    | 项目源码 | 文件源码
def enable_proxy(ProxyServer):
    proxy_state = proxy_state_menu
    #?? AutoConfigURL ???? ProxyServer
    if proxy_state.pac:
        winreg.DeleteValue(SETTINGS, 'AutoConfigURL')    
    if not proxy_state.type & 2:
        winreg.SetValueEx(SETTINGS, 'ProxyEnable', 0,  winreg.REG_DWORD, 1)
    proxy_state.type = 2
    proxy_state.http = ProxyServer.http
    proxy_state.https = ProxyServer.https
    winreg.SetValueEx(SETTINGS, 'ProxyServer', 0,  winreg.REG_SZ, proxy_state.str)
    refresh_proxy_state(1)
项目:keyrings.alt    作者:jaraco    | 项目源码 | 文件源码
def delete_password(self, service, username):
        """Delete the password for the username of the service.
        """
        try:
            key_name = r'Software\%s\Keyring' % 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)
项目:persepolis    作者:persepolisdm    | 项目源码 | 文件源码
def removestartup():
    # check if it is linux
    if os_type == 'Linux' or os_type == 'FreeBSD' or os_type == 'OpenBSD':

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

    # check if it is mac OS
    elif os_type == "Darwin":
        # 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 == '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)
项目:BingNiceWallpapers    作者:redstoneleo    | 项目源码 | 文件源码
def remove(name):
        """delete an autostart entry"""
        if exists("BingNiceWallpapers"):
            key = get_runonce()
            winreg.DeleteValue(key, name)
            winreg.CloseKey(key)
项目:OnCue    作者:featherbear    | 项目源码 | 文件源码
def load(self, data):
        """
        Prepare the content for display
        """
        self.type = data["type"]
        if self.type == "powerpoint":
            if not self.pptregistry: return False
            # https://mail.python.org/pipermail/python-win32/2012-July/012471.html
            self.PPTapplication = win32com.client.DispatchWithEvents("PowerPoint.Application", self.PPTevents)
            try:
                self.PPTpresentation = self.PPTapplication.Presentations.Open(data["path"].replace("/", "\\"),
                                                                              WithWindow=False)
                # Change PowerPoint output monitor setting (Touch and revert)
                reset = []
                try:
                    reset.append((winreg.QueryValueEx(self.pptregistry, "UseAutoMonSelection")[0],
                                  lambda value: winreg.SetValueEx(self.pptregistry, "UseAutoMonSelection", 0,
                                                                  winreg.REG_DWORD,
                                                                  value)))
                except WindowsError:
                    reset.append((None, lambda _: winreg.DeleteValue(self.pptregistry, "UseAutoMonSelection")))
                try:
                    reset.append((winreg.QueryValueEx(self.pptregistry, "DisplayMonitor")[0],
                                  lambda value: winreg.SetValueEx(self.pptregistry, "DisplayMonitor", 0, winreg.REG_SZ,
                                                                  value)))
                except WindowsError:
                    reset.append((None, lambda _: winreg.DeleteValue(self.pptregistry, "DisplayMonitor")))

                winreg.SetValueEx(self.pptregistry, "DisplayMonitor", 0, winreg.REG_SZ,
                                  self.states["screens"][self.states["display"]["outputID"]]["physical"])

                winreg.SetValueEx(self.pptregistry, "UseAutoMonSelection", 0, winreg.REG_DWORD, 0)

                self.PPTpresentation.SlideShowSettings.ShowPresenterView = False
                self.PPTpresentation.SlideShowSettings.Run()
                self.PPTpresentation.SlideShowWindow.View.AcceleratorsEnabled = False
                self.overlay.setGeometry(self.screen)
                self.overlay.showFullScreen()
                [action(value) for value, action in reset]
            except Exception as e:
                print(e)
        else:
            # Play with VLC
            self.player.set_hwnd(int(self.foreground.winId()))
            self.VLCmedia = self.vlc.media_new(data["path"])
            self.player.set_media(self.VLCmedia)