Skip to content

Commit

Permalink
v2.1 更新
Browse files Browse the repository at this point in the history
  • Loading branch information
Return-Log committed Aug 22, 2024
1 parent 162a33f commit f8a00f7
Show file tree
Hide file tree
Showing 3 changed files with 213 additions and 10 deletions.
60 changes: 54 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# 网盘图标删除器 Drive Icon Manager v2.0
# 网盘图标删除器 Drive Icon Manager v2.1

## 介绍

- 一键轻松删除Windows平台“此电脑”及“资源管理器侧边栏”中的第三方图标,使你不再受无用的网盘图标影响。

- 这些图标当然可以手动删除,但手动查找注册表是一件繁琐的事,此外“资源管理器侧边栏”中的图标路径包含用户独有的SID,直接复制网上的路径是行不通的,本程序会自动获取当前用户SID,节省自己查找的时间。

- 一件锁定注册表,使图标不再复发
- 一键锁定注册表,使图标不再复发
- 一键备份注册表项,有需要时可以恢复

## 原理

Expand All @@ -20,11 +19,15 @@

## 界面展示

![Snipaste_2024-08-22_22-04-02.png](https://s2.loli.net/2024/08/22/9koRL5h3G7p8WS4.png)

![Snipaste_2024-08-19_21-06-31.png](https://s2.loli.net/2024/08/19/2uWPh1e9paBV5xQ.png)

![Snipaste_2024-08-19_20-40-26.png](https://s2.loli.net/2024/08/19/QojfFreUpyhEKuY.png)

## 注意事项
## 详细说明

### 禁用写入权限

- 点击‘禁用写入权限’后其它软件无法读取和更改注册表,当然此程序也无法读取相应注册表,【务必】在禁用写入权限前先将无用的图标删除。

Expand All @@ -34,6 +37,48 @@

![Snipaste_2024-08-19_20-50-33.png](https://s2.loli.net/2024/08/19/Fr7NeGY6BwlDEqL.png)

### 备份注册表

- 选中需要备份的项,点击下方备份按钮,会在程序根目录下生成对应的.reg文件,需要恢复时,双击即可恢复

### 关于百度网盘图标

- 现已支持百度网盘图标的删除,将’此电脑‘标签页下两个百度网盘的项都删除即可
- 百度网盘使用的路径系统也在使用故不添加一键锁定注册表功能
- 需要永久关闭百度网盘图标可到百度网盘设置中将’在我的电脑创建快捷方式‘取消勾选

## 发行版

**运行环境:**win10/win11 非精简版系统

### 开源仓库

<https://github.com/Return-Log/Drive-Icon-Manager>

### 网盘下载

**v2.1 单文件版**【推荐下载】

https://wwif.lanzouk.com/i4uja2862t4h
密码:e1oy

================================

**v2.0 单文件版**
https://wwif.lanzouh.com/iY3TQ27veitc

密码:18kd

**v2.0 绿色版**
https://wwif.lanzouh.com/ivwHW27vel4f

=================================

**v1.1 单文件版**
https://wwif.lanzouh.com/iaj7727m1zqj

密码:czzg

## 开发环境

必要的库
Expand All @@ -47,8 +92,11 @@ import subprocess
import pyperclip
import win32security
import win32con
from PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QMessageBox, QTabWidget, QListWidget, QListWidgetItem, QTextEdit
from PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QMessageBox, \
QTabWidget, QListWidget, QListWidgetItem, QTextEdit, QTextBrowser
from PyQt6.QtCore import Qt
from markdown import markdown
import about_content # ‘关于’模块
from RegistryPermissionsManager import RegistryPermissionsManager # 修改注册表权限的模块
```

Expand Down
29 changes: 29 additions & 0 deletions about_content.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Drive Icon Manager
这是一个用于管理 Windows '此电脑' 和 '资源管理器侧边栏' 图标的工具。

## 当前版本
- v2.1
- 2024/8/22

## 更新日志:

### 2024/8/22 v2.1
- 增加对‘百度网盘’图标删除的支持
- 增加备份对应注册表功能
- 修复未选任何项时点击‘删除’时的闪退问题

### 2024/8/19 v2.0
- 添加了图形化界面
- 增添一键锁定相应注册表功能

## 关于软件
- **开源协议:GPL-3.0 license**
- **GitHub仓库<https://github.com/Return-Log/Drive-Icon-Manager>**

## 对软件的疑惑或建议
- **[向GitHub仓库提交issues](https://github.com/Return-Log/Drive-Icon-Manager/issues/new)**
- **[在吾爱破解论坛文章下回复](https://www.52pojie.cn/thread-1955346-1-1.html)**

---

Copyright © 2024 Log All rights reserved.
134 changes: 130 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
GPL-3.0 license
coding: UTF-8
"""

import os
import winreg
import ctypes
import win32api
Expand All @@ -13,12 +13,13 @@
import win32security
import win32con
from PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QMessageBox, \
QTabWidget, QListWidget, QListWidgetItem, QTextEdit
QTabWidget, QListWidget, QListWidgetItem, QTextEdit, QTextBrowser
from PyQt6.QtCore import Qt
from markdown import markdown
from RegistryPermissionsManager import RegistryPermissionsManager # 修改注册表权限的模块

# 定义版本号和链接
VERSION = "v2.0"
VERSION = "v2.1"
GITHUB_LINK = "https://github.com/Return-Log/Drive-Icon-Manager"
FORUM_LINK = "https://www.52pojie.cn/thread-1955346-1-1.html"

Expand All @@ -33,6 +34,7 @@ def write(self, message):
def flush(self):
pass


class DriveIconManager(QWidget):
def __init__(self):
super().__init__()
Expand Down Expand Up @@ -73,10 +75,12 @@ def initUI(self):
self.this_pc_tab = QWidget()
self.sidebar_tab = QWidget()
self.permissions_tab = QWidget()
self.about_tab = QWidget()

self.tab_widget.addTab(self.this_pc_tab, "此电脑")
self.tab_widget.addTab(self.sidebar_tab, "资源管理器侧边栏")
self.tab_widget.addTab(self.permissions_tab, "注册表权限")
self.tab_widget.addTab(self.about_tab, "关于")
self.tab_widget.currentChanged.connect(self.on_tab_change)

# 设置标签页布局
Expand Down Expand Up @@ -127,6 +131,26 @@ def initUI(self):
self.delete_button.clicked.connect(self.delete_selected_icon)
button_layout.addWidget(self.delete_button)

# 创建关于标签页的布局
self.about_layout = QVBoxLayout()
self.about_text_browser = QTextBrowser()

# 加载并显示关于内容
about_content = self.load_about_content()
try:
html_content = markdown(about_content)
self.about_text_browser.setHtml(html_content)
except Exception as e:
self.about_text_browser.setText(f"无法处理关于内容: {e}")

self.about_layout.addWidget(self.about_text_browser)
self.about_tab.setLayout(self.about_layout)

# 添加备份按钮
self.backup_button = QPushButton('备份选中的驱动器图标', self)
self.backup_button.clicked.connect(self.backup_selected_icon)
button_layout.addWidget(self.backup_button)

self.exit_button = QPushButton('退出程序', self)
self.exit_button.clicked.connect(self.close)
button_layout.addWidget(self.exit_button)
Expand Down Expand Up @@ -175,10 +199,18 @@ def list_drive_icons(self, base_key, path, source):
subkey_name = winreg.EnumKey(key, i)
subkey_path = f"{path}\\{subkey_name}"
subkey = winreg.OpenKey(base_key, subkey_path, 0, winreg.KEY_READ)

try:
display_name, _ = winreg.QueryValueEx(subkey, None)
except FileNotFoundError:
display_name = "无显示名称"

# 仅对 'HKEY_LOCAL_MACHINE' 进行过滤,显示 '百度网盘'
if base_key == winreg.HKEY_LOCAL_MACHINE and display_name != "百度网盘":
winreg.CloseKey(subkey)
i += 1
continue

icons.append((subkey_name, display_name, source))
winreg.CloseKey(subkey)
i += 1
Expand All @@ -191,10 +223,17 @@ def list_drive_icons(self, base_key, path, source):

def delete_drive_icon(self, index):
"""删除指定索引的驱动器图标"""
if index < 0 or index >= len(self.icons):
QMessageBox.warning(self, "未选中任何项", "请先选择一个驱动器图标再进行删除操作")
return

subkey_name, _, source = self.icons[index]
if source == '此电脑':
base_key = winreg.HKEY_CURRENT_USER
key_path = r'Software\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace'
elif source == '百度网盘':
base_key = winreg.HKEY_LOCAL_MACHINE
key_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace'
else:
base_key = winreg.HKEY_USERS
current_user_sid = self.get_current_user_sid()
Expand All @@ -210,17 +249,86 @@ def delete_drive_icon(self, index):
finally:
self.display_icons() # 删除后自动刷新

def backup_selected_icon(self):
"""备份选中的驱动器图标"""
selected_index = self.this_pc_text.currentRow() if self.selected_location == '此电脑' else self.sidebar_text.currentRow()

if selected_index < 0 or selected_index >= len(self.icons):
QMessageBox.warning(self, "无效的选择", "请先选择一个有效的驱动器图标再进行操作")
return

subkey_name, display_name, source = self.icons[selected_index]

# 根据源选择正确的根键和路径
if source == '此电脑':
base_key = winreg.HKEY_CURRENT_USER
key_path = r'Software\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace'
base_key_str = 'HKEY_CURRENT_USER'
elif source == '百度网盘':
base_key = winreg.HKEY_LOCAL_MACHINE
key_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace'
base_key_str = 'HKEY_LOCAL_MACHINE'
elif source == '资源管理器侧边栏':
base_key = winreg.HKEY_USERS
current_user_sid = self.get_current_user_sid()
key_path = fr'{current_user_sid}\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace'
base_key_str = 'HKEY_USERS'

full_key_path = f"{key_path}\\{subkey_name}"

try:
reg_file_name = f"双击恢复{display_name}图标.reg"
with open(reg_file_name, 'w', encoding='utf-16le') as reg_file:
reg_file.write("\ufeff") # 写入BOM以标识UTF-16LE编码
reg_file.write("Windows Registry Editor Version 5.00\n\n")
reg_file.write(f"[{base_key_str}\\{full_key_path}]\n")

key = winreg.OpenKey(base_key, full_key_path, 0, winreg.KEY_READ)
i = 0
while True:
try:
value_name, value_data, value_type = winreg.EnumValue(key, i)
if value_type == winreg.REG_SZ:
reg_file.write(f"\"{value_name}\"=\"{value_data}\"\n")
elif value_type == winreg.REG_DWORD:
reg_file.write(f"\"{value_name}\"=dword:{value_data:08x}\n")
elif value_type == winreg.REG_BINARY:
reg_file.write(f"\"{value_name}\"=hex:{','.join([f'{b:02x}' for b in value_data])}\n")
elif value_type == winreg.REG_MULTI_SZ:
reg_file.write(
f"\"{value_name}\"=hex(7):{','.join([f'{ord(c):02x}' for c in '\\0'.join(value_data)])},00,00\n")
elif value_type == winreg.REG_EXPAND_SZ:
reg_file.write(
f"\"{value_name}\"=hex(2):{','.join([f'{ord(c):02x}' for c in value_data])},00,00\n")
i += 1
except OSError:
break
winreg.CloseKey(key)

QMessageBox.information(self, "备份成功", f"驱动器图标已成功备份到 {reg_file_name}")

except Exception as e:
self.display_error_message(f"无法备份驱动器图标: {e}")

def display_icons(self):
"""显示所有驱动器图标"""
self.icons = []
if self.selected_location == '此电脑':
self.this_pc_text.clear()

# 列出 HKEY_CURRENT_USER 下的驱动器图标
self.icons += self.list_drive_icons(winreg.HKEY_CURRENT_USER,
r'Software\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace',
'此电脑')

# 列出 HKEY_LOCAL_MACHINE 下的 '百度网盘' 图标
self.icons += self.list_drive_icons(winreg.HKEY_LOCAL_MACHINE,
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace',
'百度网盘')

if self.icons:
for index, (subkey_name, display_name, source) in enumerate(self.icons):
item = QListWidgetItem(f"{subkey_name} - {display_name}")
item = QListWidgetItem(f"{subkey_name} - {display_name} ({source})")
self.this_pc_text.addItem(item)
else:
item = QListWidgetItem("此电脑未找到驱动器图标")
Expand Down Expand Up @@ -387,6 +495,24 @@ def on_tab_change(self, index):
elif index == 2:
self.display_permissions()

def load_about_content(self):
"""加载关于内容"""
try:
if getattr(sys, 'frozen', False):
# 如果是打包后的程序
about_file_path = os.path.join(sys._MEIPASS, 'about_content.md')
else:
# 如果是开发环境
about_file_path = 'about_content.md'

with open(about_file_path, 'r', encoding='utf-8') as file:
about_text = file.read()

return about_text if about_text else "关于内容为空。"

except FileNotFoundError:
return "关于内容文件未找到。"


if __name__ == '__main__':
app = QApplication(sys.argv)
Expand Down

0 comments on commit f8a00f7

Please sign in to comment.