本文整理汇总了Python中_winreg.DeleteKey方法的典型用法代码示例。如果您正苦于以下问题:Python _winreg.DeleteKey方法的具体用法?Python _winreg.DeleteKey怎么用?Python _winreg.DeleteKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_winreg
的用法示例。
在下文中一共展示了_winreg.DeleteKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unregister
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteKey [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: del_subkey
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteKey [as 别名]
def del_subkey(self,name):
"""Delete the named subkey, and any values or keys it contains."""
self.sam |= KEY_WRITE
subkey = self.get_subkey(name)
subkey.clear()
_winreg.DeleteKey(subkey.parent.hkey,subkey.name)
示例3: DllUnregisterServer
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteKey [as 别名]
def DllUnregisterServer():
import _winreg
try:
key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,
"directory\\shellex\\CopyHookHandlers\\" +
ShellExtension._reg_desc_)
except WindowsError, details:
import errno
if details.errno != errno.ENOENT:
raise
示例4: DllUnregisterServer
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteKey [as 别名]
def DllUnregisterServer():
import _winreg
try:
key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,
"Folder\\ShellEx\\ColumnHandlers\\" + \
str(ColumnProvider._reg_clsid_) )
except WindowsError, details:
import errno
if details.errno != errno.ENOENT:
raise
示例5: DllUnregisterServer
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteKey [as 别名]
def DllUnregisterServer():
import _winreg
kn = r"Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\%s" \
% (EmptyVolumeCache._reg_desc_,)
try:
key = _winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE, kn)
except WindowsError, details:
import errno
if details.errno != errno.ENOENT:
raise
示例6: DllUnregisterServer
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteKey [as 别名]
def DllUnregisterServer():
import _winreg
try:
key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,
"Python.File\\shellex\\ContextMenuHandlers\\PythonSample")
except WindowsError, details:
import errno
if details.errno != errno.ENOENT:
raise
示例7: DllUnregisterServer
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteKey [as 别名]
def DllUnregisterServer():
import _winreg
paths = [
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\Namespace\\" + ShellFolder._reg_clsid_,
"%s\\shellex\\ContextMenuHandlers\\%s" % (ContextMenu._context_menu_type_, ContextMenu._reg_desc_),
]
for path in paths:
try:
_winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE, path)
except WindowsError, details:
import errno
if details.errno != errno.ENOENT:
print "FAILED to remove %s: %s" % (path, details)
示例8: DllUnregisterServer
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteKey [as 别名]
def DllUnregisterServer():
import _winreg
try:
key = _winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \
"Explorer\\Desktop\\Namespace\\" + \
ShellFolderRoot._reg_clsid_)
except WindowsError, details:
import errno
if details.errno != errno.ENOENT:
raise
示例9: UnregisterAddin
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteKey [as 别名]
def UnregisterAddin(klass):
import _winreg
try:
_winreg.DeleteKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Excel\\Addins\\" + klass._reg_progid_)
except WindowsError:
pass
示例10: UnregisterAddin
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteKey [as 别名]
def UnregisterAddin(klass):
import _winreg
try:
_winreg.DeleteKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Outlook\\Addins\\" + klass._reg_progid_)
except WindowsError:
pass
示例11: __delitem__
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteKey [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
示例12: restore
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteKey [as 别名]
def restore(self, key, value=''):
""" Restore to the last registry known state
"""
if self.no_restore is False:
new_sk = self.last_created['new_sk']
k = self.last_created['key']
exist_sk = self.last_created['existing_sk']
self.del_value(key, value)
if new_sk is not None:
for i in range(len(new_sk)):
if i == 0:
try:
winreg.DeleteKey(k, "\\".join(exist_sk + new_sk))
except WindowsError as error:
pass
else:
try:
winreg.DeleteKey(k, "\\".join(
exist_sk + new_sk[:-i]))
except WindowsError as error:
pass
self.last_created['new_sk'] = None
self.last_created['existing_sk'] = None
self.last_created['key'] = None
示例13: delete_key
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteKey [as 别名]
def delete_key(self, key, subkey):
""" Deletes a particular key
"""
try:
return winreg.DeleteKey(key, subkey)
except WindowsError as error:
print "Error al eliminar la clave"
示例14: restore
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteKey [as 别名]
def restore(self, key, value=''):
""" Restore to the last registry known state
"""
if self.no_restore is False:
new_sk = self.last_created['new_sk']
k = self.last_created['key']
exist_sk = self.last_created['existing_sk']
self.del_value(key, value)
if new_sk is not None:
for i in range(len(new_sk)):
if i == 0:
try:
winreg.DeleteKey(k, "\\".join(exist_sk + new_sk))
except WindowsError as error:
return None
else:
try:
winreg.DeleteKey(k, "\\".join(
exist_sk + new_sk[:-i]))
except WindowsError as error:
return None
self.last_created['new_sk'] = None
self.last_created['existing_sk'] = None
self.last_created['key'] = None
return True
示例15: delete_key
# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import DeleteKey [as 别名]
def delete_key(self, key, subkey):
""" Deletes a particular key
"""
try:
return winreg.DeleteKey(key, subkey)
except WindowsError as error:
return None