更新: 1. 优化未激活状态下的购买信息提示框 2. 添加一键复制功能 3. 更新版本到3.0.9
This commit is contained in:
@@ -2,6 +2,7 @@ import os
|
||||
import winreg
|
||||
import logging
|
||||
from pathlib import Path
|
||||
import uuid
|
||||
|
||||
class CursorRegistry:
|
||||
"""Cursor注册表操作工具类"""
|
||||
@@ -9,14 +10,27 @@ class CursorRegistry:
|
||||
def __init__(self):
|
||||
self.cursor_path = Path(os.path.expanduser("~")) / "AppData" / "Local" / "Programs" / "Cursor"
|
||||
self.app_path = self.cursor_path / "resources" / "app"
|
||||
self.machine_guid_path = r"SOFTWARE\Microsoft\Cryptography"
|
||||
self.machine_guid_name = "MachineGuid"
|
||||
|
||||
def refresh_registry(self) -> bool:
|
||||
"""刷新Cursor相关的注册表项
|
||||
|
||||
"""刷新注册表
|
||||
Returns:
|
||||
bool: 是否成功
|
||||
"""
|
||||
try:
|
||||
# 生成新的GUID
|
||||
new_guid = str(uuid.uuid4())
|
||||
|
||||
# 修改 MachineGuid
|
||||
try:
|
||||
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, self.machine_guid_path, 0, winreg.KEY_ALL_ACCESS) as key:
|
||||
winreg.SetValueEx(key, self.machine_guid_name, 0, winreg.REG_SZ, new_guid)
|
||||
logging.info(f"更新 MachineGuid 成功: {new_guid}")
|
||||
except Exception as e:
|
||||
logging.error(f"更新 MachineGuid 失败: {str(e)}")
|
||||
return False
|
||||
|
||||
# 获取Cursor安装路径
|
||||
cursor_exe = self.cursor_path / "Cursor.exe"
|
||||
if not cursor_exe.exists():
|
||||
@@ -42,7 +56,7 @@ class CursorRegistry:
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"刷新注册表过程出错: {str(e)}")
|
||||
logging.error(f"刷新注册表失败: {str(e)}")
|
||||
return False
|
||||
|
||||
def clean_registry(self) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user