From 681b674eb2a04117209d796653702519bf4409ce Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Wed, 18 Feb 2026 22:03:30 +0800 Subject: [PATCH] =?UTF-8?q?improve:=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Helpers/AutoUpdateHelper.cs | 28 ++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Ink Canvas/Helpers/AutoUpdateHelper.cs b/Ink Canvas/Helpers/AutoUpdateHelper.cs index b11cc574..1ceeda25 100644 --- a/Ink Canvas/Helpers/AutoUpdateHelper.cs +++ b/Ink Canvas/Helpers/AutoUpdateHelper.cs @@ -1341,13 +1341,25 @@ namespace Ink_Canvas.Helpers } } - // 安装新版本应用 - 优化版本,不使用命令行 + // 安装新版本应用 public static void InstallNewVersionApp(string version, bool isInSilence) { + bool wasProcessProtectionEnabled = false; + try + { + wasProcessProtectionEnabled = ProcessProtectionManager.Enabled; + } + catch + { + } + try { App.IsUpdateInstalling = true; - try { ProcessProtectionManager.SetEnabled(false); } catch { } + if (wasProcessProtectionEnabled) + { + try { ProcessProtectionManager.SetEnabled(false); } catch { } + } // 在更新前备份设置文件 try @@ -1509,6 +1521,18 @@ namespace Ink_Canvas.Helpers LogHelper.WriteLogToFile($"AutoUpdate | 内部异常: {ex.InnerException.Message}", LogHelper.LogType.Error); } } + finally + { + // 确保无论更新成功还是失败,都恢复标志位和进程保护状态 + App.IsUpdateInstalling = false; + try + { + ProcessProtectionManager.SetEnabled(wasProcessProtectionEnabled); + } + catch + { + } + } } // 处理更新模式的启动参数