Skip to content

Commit

Permalink
Added the possibility to launch the app on start (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Jan 6, 2024
1 parent e88103a commit d518f96
Show file tree
Hide file tree
Showing 4 changed files with 473 additions and 161 deletions.
12 changes: 12 additions & 0 deletions PermaTop/Classes/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,18 @@ public static void ChangeLanguage()
}
}

public static void SetLaunchAtStart(bool launchAtStart)
{
var key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (launchAtStart)
{
key?.SetValue("PermaTop", Environment.ProcessPath ?? $@"{AppContext.BaseDirectory}\PermaTop.exe");
return;
}

key?.DeleteValue("PermaTop", false);
}

[DllImport("user32.dll")]
internal static extern IntPtr GetClassLong(IntPtr hWnd, int nIndex);

Expand Down
2 changes: 2 additions & 0 deletions PermaTop/Classes/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ public class Settings
public Languages Language { get; set; }
public bool IsFirstRun { get; set; }
public bool CheckUpdateOnStart { get; set; }
public bool? LaunchAtStart { get; set; }
public Settings()
{
Theme = Themes.System;
Language = Languages.Default;
IsFirstRun = true;
CheckUpdateOnStart = true;
LaunchAtStart = false;
}
}
Loading

0 comments on commit d518f96

Please sign in to comment.