當前位置: 首頁>>代碼示例>>Python>>正文


Python winreg.DeleteKey方法代碼示例

本文整理匯總了Python中winreg.DeleteKey方法的典型用法代碼示例。如果您正苦於以下問題:Python winreg.DeleteKey方法的具體用法?Python winreg.DeleteKey怎麽用?Python winreg.DeleteKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在winreg的用法示例。


在下文中一共展示了winreg.DeleteKey方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _delete_key_if_empty

# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import DeleteKey [as 別名]
def _delete_key_if_empty(self, service):
        key_name = self._key_for_service(service)
        key = winreg.OpenKey(
            winreg.HKEY_CURRENT_USER, key_name, 0, winreg.KEY_ALL_ACCESS
        )
        try:
            winreg.EnumValue(key, 0)
            return
        except WindowsError:
            pass
        winreg.CloseKey(key)

        # it's empty; delete everything
        while key_name != 'Software':
            parent, sep, base = key_name.rpartition('\\')
            key = winreg.OpenKey(
                winreg.HKEY_CURRENT_USER, parent, 0, winreg.KEY_ALL_ACCESS
            )
            winreg.DeleteKey(key, base)
            winreg.CloseKey(key)
            key_name = parent 
開發者ID:jaraco,項目名稱:keyrings.alt,代碼行數:23,代碼來源:Windows.py

示例2: uninstaller_cleanup

# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import DeleteKey [as 別名]
def uninstaller_cleanup():
    if sys.platform == 'win32':
        try:
            with winreg.OpenKey(
                winreg.HKEY_CURRENT_USER,
                    r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
                    access=winreg.KEY_WRITE) as reg:
                winreg.DeleteKey(reg, 'SimNIBS')
        except FileNotFoundError:
            pass 
開發者ID:simnibs,項目名稱:simnibs,代碼行數:12,代碼來源:postinstall_simnibs.py

示例3: 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) 
開發者ID:NVDARemote,項目名稱:NVDARemote,代碼行數:8,代碼來源:regobj.py

示例4: del_key

# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import DeleteKey [as 別名]
def del_key(self):
        try:
            k =  winreg.DeleteKey(self.key, self.subkey)
            to_return = self._return_success(k)
            self.current_key = None
        except WindowsError as e:
            to_return = self._return_error(str(e))
        return to_return 
開發者ID:Josue87,項目名稱:BoomER,代碼行數:10,代碼來源:registry.py

示例5: 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 
開發者ID:ElevenPaths,項目名稱:uac-a-mola,代碼行數:30,代碼來源:ext_server_uacamola.py

示例6: 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 
開發者ID:ElevenPaths,項目名稱:uac-a-mola,代碼行數:9,代碼來源:ext_server_uacamola.py

示例7: _remove_jupyter_here

# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import DeleteKey [as 別名]
def _remove_jupyter_here(all_users):
    if all_users:
        h_key_base = winreg.HKEY_LOCAL_MACHINE
        install_type = "all users"
    else:
        h_key_base = winreg.HKEY_CURRENT_USER
        install_type = "single user"

    for terminal in ('qtconsole', 'notebook', 'lab'):
        try:
            winreg.DeleteKey(
                h_key_base,
                r'Software\Classes\Directory\shell\jupyter_%s_here%s\Command' % (
                terminal, CONDA_ENV_LABEL.replace(" ", "_")))
            winreg.DeleteKey(
                h_key_base,
                r'Software\Classes\Directory\shell\jupyter_%s_here%s' % (
                terminal, CONDA_ENV_LABEL.replace(" ", "_")))
            winreg.DeleteKey(
                h_key_base,
                r'Software\Classes\Directory\Background\shell\jupyter_%s_here%s\Command' % (
                terminal, CONDA_ENV_LABEL.replace(" ", "_")))
            winreg.DeleteKey(
                h_key_base,
                r'Software\Classes\Directory\Background\shell\jupyter_%s_here%s' % (
                terminal, CONDA_ENV_LABEL.replace(" ", "_")))
            print("Jupyter %s here%s context menu entry removed for %s." % (
                    terminal, CONDA_ENV_LABEL, install_type))
        except FileNotFoundError:
            # If this fails it is because it was not installed, so nothing to
            # worry about.
            pass 
開發者ID:hyperspy,項目名稱:start_jupyter_cm,代碼行數:34,代碼來源:windows.py


注:本文中的winreg.DeleteKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。