本文整理汇总了Python中_winreg.DeleteValue方法的典型用法代码示例。如果您正苦于以下问题:Python _winreg.DeleteValue方法的具体用法?Python _winreg.DeleteValue怎么用?Python _winreg.DeleteValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_winreg
的用法示例。
在下文中一共展示了_winreg.DeleteValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unregister
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteValue [as 别名]
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
#
示例2: enforce_shortcut
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteValue [as 别名]
def enforce_shortcut(config, log_func):
if os.name != 'nt':
return
path = win32api.GetModuleFileName(0)
if 'python' in path.lower():
# oops, running the .py too lazy to make that work
path = r"C:\Program Files\BitTorrent\bittorrent.exe"
root_key = _winreg.HKEY_CURRENT_USER
subkey = r'Software\Microsoft\Windows\CurrentVersion\run'
key = _winreg.CreateKey(root_key, subkey)
if config['launch_on_startup']:
_winreg.SetValueEx(key, app_name, 0, _winreg.REG_SZ,
'"%s" --force_start_minimized' % path)
else:
try:
_winreg.DeleteValue(key, app_name)
except WindowsError, e:
# value doesn't exist
pass
示例3: cleanup
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteValue [as 别名]
def cleanup(base_key_full_path):
"""Performs the clean up of AltFS applicable values from the Registry"""
hive, base_key_path = split_key_path_to_hive_and_path(base_key_full_path)
with _winreg.OpenKey(
HIVES[hive], base_key_path, _winreg.KEY_SET_VALUE) as base_key:
buckets_names = get_sub_keys(base_key)
for bucket_name in buckets_names:
print "iterating key: %s" % bucket_name
values_to_delete = []
with get_bucket_key(
HIVES[hive], "%s\\%s" % (base_key_path, bucket_name)) as key:
for value_name in get_sub_values(key):
print "iterating value name: %s" % value_name
if is_value_name_applicable(buckets_names, value_name):
values_to_delete.append(value_name)
with get_bucket_key(
HIVES[hive], "%s\\%s" % (base_key_path, bucket_name),
desired_access=_winreg.KEY_SET_VALUE) as key:
for value_name in values_to_delete:
print "-- going to delete: %s" % value_name
_winreg.DeleteValue(key, value_name)
示例4: __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,))
示例5: DllUnregisterServer
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteValue [as 别名]
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
示例6: 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
示例7: remove
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteValue [as 别名]
def remove(name):
if not exists(name):
return
"""delete an autostart entry"""
key = get_runonce()
_winreg.DeleteValue(key, name)
_winreg.CloseKey(key)
示例8: 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)))
示例9: _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)))
示例10: __delitem__
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteValue [as 别名]
def __delitem__(self, k):
key, subkey = self._compute_subkey(k)
with _winreg.OpenKey(self._hive, key,
0, _winreg.KEY_ALL_ACCESS) as root_key:
try:
_winreg.DeleteValue(root_key, subkey)
except WindowsError:
try:
_winreg.DeleteKey(root_key, subkey)
except WindowsError:
raise KeyError
示例11: 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:
print "Error al eliminar el valor"
示例12: 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
示例13: _remove_registry_key
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteValue [as 别名]
def _remove_registry_key(value=None, name='Java-Update-Manager'):
try:
if _methods['registry_key'].established:
value = _methods['registry_key'].result
try:
key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 0, _winreg.KEY_ALL_ACCESS)
_winreg.DeleteValue(key, name)
_winreg.CloseKey(key)
return (False, None)
except: pass
return (_methods['registry_key'].established, _methods['registry_key'].result)
except Exception as e:
util.log(str(e))
示例14: remove
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteValue [as 别名]
def remove(name):
"""delete an autostart entry"""
key = get_runonce()
_winreg.DeleteValue(key, name)
_winreg.CloseKey(key)
示例15: write_language_file
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteValue [as 别名]
def write_language_file(lang):
"""Writes the language file. The language file contains the
name of the selected language, not any translations."""
if lang != '': # system default
get_language(lang)
if os.name == 'nt':
regko = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, "Software\\BitTorrent")
if lang == '':
_winreg.DeleteValue(regko, "Language")
else:
lcid = None
# I want two-way dicts
for id, code in language.locale_sucks.iteritems():
if code.lower() == lang.lower():
lcid = id
break
if not lcid:
raise KeyError(lang)
_winreg.SetValueEx(regko, "Language", 0, _winreg.REG_SZ, str(lcid))
else:
lang_file_name = language_path()
lang_file = open(lang_file_name, 'w')
lang_file.write(lang)
lang_file.close()