mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix crash when user does not have access to registry startup keys
Instead log an error about non-critical functionality and continue on.
This commit is contained in:
parent
b079aa3b29
commit
c3a67d46f6
1 changed files with 27 additions and 7 deletions
|
|
@ -4,6 +4,7 @@ using Flow.Launcher.Core.Resource;
|
||||||
using Flow.Launcher.Helper;
|
using Flow.Launcher.Helper;
|
||||||
using Flow.Launcher.Infrastructure;
|
using Flow.Launcher.Infrastructure;
|
||||||
using Flow.Launcher.Infrastructure.Hotkey;
|
using Flow.Launcher.Infrastructure.Hotkey;
|
||||||
|
using Flow.Launcher.Infrastructure.Logger;
|
||||||
using Flow.Launcher.Infrastructure.UserSettings;
|
using Flow.Launcher.Infrastructure.UserSettings;
|
||||||
using Flow.Launcher.Plugin;
|
using Flow.Launcher.Plugin;
|
||||||
using Flow.Launcher.Plugin.SharedCommands;
|
using Flow.Launcher.Plugin.SharedCommands;
|
||||||
|
|
@ -70,24 +71,43 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
public static void SetStartup()
|
public static void SetStartup()
|
||||||
{
|
{
|
||||||
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
|
try
|
||||||
key?.SetValue(Constant.FlowLauncher, Constant.ExecutablePath);
|
{
|
||||||
|
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
|
||||||
|
key?.SetValue(Constant.FlowLauncher, Constant.ExecutablePath);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error("SettingsWindow", $"Ignoring non-critical registry error (user permissions?): {e}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveStartup()
|
private void RemoveStartup()
|
||||||
{
|
{
|
||||||
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
|
try
|
||||||
key?.DeleteValue(Constant.FlowLauncher, false);
|
{
|
||||||
|
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
|
||||||
|
key?.DeleteValue(Constant.FlowLauncher, false);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error("SettingsWindow", $"Ignoring non-critical registry error (user permissions?): {e}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool StartupSet()
|
public static bool StartupSet()
|
||||||
{
|
{
|
||||||
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
|
try
|
||||||
var path = key?.GetValue(Constant.FlowLauncher) as string;
|
|
||||||
if (path != null)
|
|
||||||
{
|
{
|
||||||
|
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
|
||||||
|
var path = key?.GetValue(Constant.FlowLauncher) as string;
|
||||||
return path == Constant.ExecutablePath;
|
return path == Constant.ExecutablePath;
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error("SettingsWindow", $"Ignoring non-critical registry error (user permissions?): {e}");
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue