From af3c22c38c33ffdd88c77f7d97d20531a1dff5f8 Mon Sep 17 00:00:00 2001 From: Robin Krom Date: Wed, 17 Aug 2022 23:08:59 +0200 Subject: [PATCH] Optimized the code to find the office executable even more. --- src/Greenshot.Plugin.Office/OfficeUtils.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Greenshot.Plugin.Office/OfficeUtils.cs b/src/Greenshot.Plugin.Office/OfficeUtils.cs index 770f8b1e8..4b828c558 100644 --- a/src/Greenshot.Plugin.Office/OfficeUtils.cs +++ b/src/Greenshot.Plugin.Office/OfficeUtils.cs @@ -35,16 +35,9 @@ internal static class OfficeUtils foreach (string officeVersion in rootKey.GetSubKeyNames().Where(r => r.Contains(".")).Reverse()) { - using RegistryKey officeKey = Registry.LocalMachine.OpenSubKey(strRootKey + "\\" + officeVersion); - if (officeKey is null) continue; - - using RegistryKey programKey = officeKey.OpenSubKey(strKeyName); - if (programKey is null) continue; - - using RegistryKey installRootKey = programKey.OpenSubKey("InstallRoot"); + using RegistryKey installRootKey = Registry.LocalMachine.OpenSubKey($@"{strRootKey}\{officeVersion}\{strKeyName}\InstallRoot"); if (installRootKey == null) continue; - - return installRootKey.GetValue("Path") + "\\" + exeName; + return $@"{installRootKey.GetValue("Path")}\{exeName}"; } } return string.Empty;