diff --git a/Ink Canvas/MainWindow_cs/MW_PPT.cs b/Ink Canvas/MainWindow_cs/MW_PPT.cs index 9a464022..c13e9cb1 100644 --- a/Ink Canvas/MainWindow_cs/MW_PPT.cs +++ b/Ink Canvas/MainWindow_cs/MW_PPT.cs @@ -15,6 +15,7 @@ using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Threading; +using Microsoft.Win32; using Application = System.Windows.Application; using File = System.IO.File; using MessageBox = System.Windows.MessageBox; @@ -68,6 +69,46 @@ namespace Ink_Canvas { } } if (pptApplication == null) throw new Exception(); + + // Office安装检测及注册表操作 + try { + // 获取Office版本 + string officeVersion = pptApplication.Version; + string regPath = $"Software\\Microsoft\\Office\\{officeVersion}\\Common\\Security"; + + // 验证注册表路径有效性 + using (RegistryKey baseKey = Registry.CurrentUser.OpenSubKey(regPath)) { + if (baseKey == null) { + LogHelper.WriteLogToFile("注册表路径不存在: " + regPath, LogHelper.LogType.Warning); + return; + } + + // 备份注册表项 + string backupPath = Path.Combine(Settings.Automation.AutoSavedStrokesLocation, "RegistryBackups"); + if (!Directory.Exists(backupPath)) Directory.CreateDirectory(backupPath); + string backupFile = Path.Combine(backupPath, $"SecurityBackup_{DateTime.Now:yyyyMMddHHmmss}.reg"); + using (StreamWriter sw = new StreamWriter(backupFile)) { + sw.WriteLine($"Windows Registry Editor Version 5.00\n\n[{Registry.CurrentUser.Name}\\{regPath}]"); + foreach (string valueName in baseKey.GetValueNames()) { + object value = baseKey.GetValue(valueName); + sw.WriteLine($"\"{valueName}\"=dword:{((int)value):x8}"); + } + } + + // 处理DisableProtectedView值 + using (RegistryKey key = Registry.CurrentUser.CreateSubKey(regPath, true)) { + if (key.GetValue("DisableProtectedView") == null) { + key.CreateSubKey(regPath, RegistryKeyPermissionCheck.ReadWriteSubTree); + key.SetValue("DisableProtectedView", 1, RegistryValueKind.DWord); + } else { + key.SetValue("DisableProtectedView", 1, RegistryValueKind.DWord); + } + } + } + } catch (Exception regEx) { + LogHelper.WriteLogToFile("注册表操作失败: " + regEx.ToString(), LogHelper.LogType.Error); + } + StackPanelPPTControls.Visibility = Visibility.Visible; } catch (Exception ex) { diff --git a/Ink Canvas/dist/InkCanvasForClass.exe b/Ink Canvas/dist/InkCanvasForClass.exe index 614399be..ee0e0a9e 100644 Binary files a/Ink Canvas/dist/InkCanvasForClass.exe and b/Ink Canvas/dist/InkCanvasForClass.exe differ