From 637685b8a97a253e01e9da56de5b2e7dcc8a44ec Mon Sep 17 00:00:00 2001 From: Jaex Date: Mon, 12 Oct 2015 11:26:21 +0300 Subject: [PATCH] Check registry target path --- ShareX.HelpersLib/Helpers/RegistryHelpers.cs | 2 +- ShareX.HelpersLib/Helpers/ShortcutHelpers.cs | 2 ++ ShareX/IntegrationHelpers.cs | 14 ++++---------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/ShareX.HelpersLib/Helpers/RegistryHelpers.cs b/ShareX.HelpersLib/Helpers/RegistryHelpers.cs index b5f3e13e9..ca44477d9 100644 --- a/ShareX.HelpersLib/Helpers/RegistryHelpers.cs +++ b/ShareX.HelpersLib/Helpers/RegistryHelpers.cs @@ -96,7 +96,7 @@ public static bool CheckShellContextMenu() { try { - return CheckRegistry(ShellExtMenuFilesCmd) && CheckRegistry(ShellExtMenuDirectoryCmd); + return CheckRegistry(ShellExtMenuFilesCmd, null, ShellExtPath) && CheckRegistry(ShellExtMenuDirectoryCmd, null, ShellExtPath); } catch (Exception e) { diff --git a/ShareX.HelpersLib/Helpers/ShortcutHelpers.cs b/ShareX.HelpersLib/Helpers/ShortcutHelpers.cs index 9f4fb0250..8a1118774 100644 --- a/ShareX.HelpersLib/Helpers/ShortcutHelpers.cs +++ b/ShareX.HelpersLib/Helpers/ShortcutHelpers.cs @@ -70,6 +70,8 @@ private static bool Create(string shortcutPath, string targetPath, string argume { if (!string.IsNullOrEmpty(shortcutPath) && !string.IsNullOrEmpty(targetPath) && File.Exists(targetPath)) { + Delete(shortcutPath); + try { IWshShell wsh = new WshShellClass(); diff --git a/ShareX/IntegrationHelpers.cs b/ShareX/IntegrationHelpers.cs index 8d5a8d0b2..a40094e20 100644 --- a/ShareX/IntegrationHelpers.cs +++ b/ShareX/IntegrationHelpers.cs @@ -35,27 +35,21 @@ public static class IntegrationHelpers { private static string GetStartupTargetPath() { - string path; - #if STEAM - path = Helpers.GetAbsolutePath("../ShareX_Launcher.exe"); + return Helpers.GetAbsolutePath("../ShareX_Launcher.exe"); #else - path = Application.ExecutablePath; + return Application.ExecutablePath; #endif - - return path; } public static bool CheckStartupShortcut() { - string targetPath = GetStartupTargetPath(); - return ShortcutHelpers.CheckShortcut(Environment.SpecialFolder.Startup, targetPath); + return ShortcutHelpers.CheckShortcut(Environment.SpecialFolder.Startup, GetStartupTargetPath()); } public static void CreateStartupShortcut(bool create) { - string targetPath = GetStartupTargetPath(); - ShortcutHelpers.SetShortcut(create, Environment.SpecialFolder.Startup, targetPath, "-silent"); + ShortcutHelpers.SetShortcut(create, Environment.SpecialFolder.Startup, GetStartupTargetPath(), "-silent"); } public static bool CheckShellContextMenuButton()