Check registry target path

This commit is contained in:
Jaex 2015-10-12 11:26:21 +03:00
parent c67bfad28a
commit 637685b8a9
3 changed files with 7 additions and 11 deletions

View file

@ -96,7 +96,7 @@ public static bool CheckShellContextMenu()
{ {
try try
{ {
return CheckRegistry(ShellExtMenuFilesCmd) && CheckRegistry(ShellExtMenuDirectoryCmd); return CheckRegistry(ShellExtMenuFilesCmd, null, ShellExtPath) && CheckRegistry(ShellExtMenuDirectoryCmd, null, ShellExtPath);
} }
catch (Exception e) catch (Exception e)
{ {

View file

@ -70,6 +70,8 @@ private static bool Create(string shortcutPath, string targetPath, string argume
{ {
if (!string.IsNullOrEmpty(shortcutPath) && !string.IsNullOrEmpty(targetPath) && File.Exists(targetPath)) if (!string.IsNullOrEmpty(shortcutPath) && !string.IsNullOrEmpty(targetPath) && File.Exists(targetPath))
{ {
Delete(shortcutPath);
try try
{ {
IWshShell wsh = new WshShellClass(); IWshShell wsh = new WshShellClass();

View file

@ -35,27 +35,21 @@ public static class IntegrationHelpers
{ {
private static string GetStartupTargetPath() private static string GetStartupTargetPath()
{ {
string path;
#if STEAM #if STEAM
path = Helpers.GetAbsolutePath("../ShareX_Launcher.exe"); return Helpers.GetAbsolutePath("../ShareX_Launcher.exe");
#else #else
path = Application.ExecutablePath; return Application.ExecutablePath;
#endif #endif
return path;
} }
public static bool CheckStartupShortcut() public static bool CheckStartupShortcut()
{ {
string targetPath = GetStartupTargetPath(); return ShortcutHelpers.CheckShortcut(Environment.SpecialFolder.Startup, GetStartupTargetPath());
return ShortcutHelpers.CheckShortcut(Environment.SpecialFolder.Startup, targetPath);
} }
public static void CreateStartupShortcut(bool create) public static void CreateStartupShortcut(bool create)
{ {
string targetPath = GetStartupTargetPath(); ShortcutHelpers.SetShortcut(create, Environment.SpecialFolder.Startup, GetStartupTargetPath(), "-silent");
ShortcutHelpers.SetShortcut(create, Environment.SpecialFolder.Startup, targetPath, "-silent");
} }
public static bool CheckShellContextMenuButton() public static bool CheckShellContextMenuButton()