我们从Python开源项目中,提取了以下32个代码示例,用于说明如何使用_winreg.DeleteValue()。
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 #
def selfdestruct(plat): if plat == 'win': import _winreg from _winreg import HKEY_CURRENT_USER as HKCU run_key = r'Software\Microsoft\Windows\CurrentVersion\Run' try: reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_ALL_ACCESS) _winreg.DeleteValue(reg_key, 'br') _winreg.CloseKey(reg_key) except WindowsError: pass elif plat == 'nix': pass elif plat == 'mac': pass # self delete os.remove(sys.argv[0]) sys.exit(0)
def selfdestruct(plat): if plat == 'win': import _winreg from _winreg import HKEY_CURRENT_USER as HKCU run_key = r'Software\Microsoft\Windows\CurrentVersion\Run' try: reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_ALL_ACCESS) _winreg.DeleteValue(reg_key, 'br') _winreg.CloseKey(reg_key) except WindowsError: pass elif plat == 'nix': pass elif plat == 'mac': pass os.remove(sys.argv[0]) sys.exit(0)
def selfdestruct(plat): if plat == 'win': import _winreg from _winreg import HKEY_CURRENT_USER as HKCU try: reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_ALL_ACCESS) _winreg.DeleteValue(reg_key, 'br') _winreg.CloseKey(reg_key) except WindowsError: pass elif plat == 'nix': pass elif plat == 'mac': pass # self delete basicRAT os.remove(sys.argv[0]) sys.exit(0)
def selfdestruct(plat): if plat == 'win': import _winreg from _winreg import HKEY_CURRENT_USER as HKCU run_key = r'Software\Microsoft\Windows\CurrentVersion\Run' try: reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_ALL_ACCESS) _winreg.DeleteValue(reg_key, 'br') _winreg.CloseKey(reg_key) except WindowsError: pass elif plat == 'nix': pass elif plat == 'mac': pass # self delete basicRAT os.remove(sys.argv[0]) sys.exit(0)
def __del_values(self): 'Private class method.' try: while True: _winreg.DeleteValue(self.__self, _winreg.EnumValue(self.__self, 0)[0]) except EnvironmentError: pass
def __del_value(self): 'Private class method.' _winreg.DeleteValue(self.__self, '')
def __delitem__(self, key): 'Delete the specified value.' _winreg.DeleteValue(self.__self, key)
def __del_values(self): 'Private class method.' try: while True: _winreg.DeleteValue(self.__key, _winreg.EnumValue(self.__key, 0)[0]) except EnvironmentError: pass
def __del_value(self): 'Private class method.' _winreg.DeleteValue(self.__key, '')
def __delitem__(self, key): 'Delete the specified value.' _winreg.DeleteValue(self.__key, key)
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
def del_value(self, key, value=''): if self.no_restore is False: try: return winreg.DeleteValue(key, value) except WindowsError as error: print "Error al eliminar el valor"
def remove(name): if not exists(name): return """delete an autostart entry""" key = get_runonce() _winreg.DeleteValue(key, name) _winreg.CloseKey(key)
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
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,))
def __delitem__(self, key): # Delete a string value or a subkey, depending on the type try: item = self[key] except: return # Silently ignore bad keys itemtype = type(item) if itemtype is str: _winreg.DeleteValue(self.keyhandle, key) elif isinstance(item, RegistryDict): # Delete everything in the subkey, then the subkey itself item.clear() _winreg.DeleteKey(self.keyhandle, key) else: raise ValueError, "Unknown item type in RegistryDict"
def set_proxy(keyList): if keyList.has_key('AutoConfigURL'): _winreg.DeleteValue(key, 'AutoConfigURL') if keyList['ProxyEnable'] != 1: _winreg.SetValueEx(key, 'ProxyEnable', 0, _winreg.REG_DWORD, 1) if not keyList.has_key('ProxyServer'): _winreg.CreateKey(key, 'ProxyServer') _winreg.SetValueEx(key, 'ProxyServer', 0, _winreg.REG_SZ, PROXY_PORT) elif keyList['ProxyServer'] != PROXY_PORT: _winreg.SetValueEx(key, 'ProxyServer', 0, _winreg.REG_SZ, PROXY_PORT)
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)
def setAutoRunWithOsStart(key,app,start=True): import _winreg try: r = _winreg.OpenKey( _winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run",0,_winreg.KEY_WRITE) if start: _winreg.SetValueEx(r,key,0,_winreg.REG_SZ,app) else: _winreg.DeleteValue(r,key) except: traceback.print_exc()
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)