Skip to content

Commit

Permalink
possibly address #796
Browse files Browse the repository at this point in the history
  • Loading branch information
Spiritreader committed Nov 28, 2023
1 parent 46e7cb5 commit 57f35ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion AutoDarkModeSvc/AutoDarkModeSvc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net7.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
<UseWindowsForms>true</UseWindowsForms>
<Version>10.4.2.0</Version>
<Version>10.4.2.1</Version>
<AssemblyName>AutoDarkModeSvc</AssemblyName>
<ApplicationIcon>..\adm_tray_new.ico</ApplicationIcon>
<StartupObject>AutoDarkModeSvc.Program</StartupObject>
Expand Down
8 changes: 7 additions & 1 deletion AutoDarkModeSvc/Handlers/RegistryHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,14 @@ public static bool AddAutoStart()
{
try
{
using RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
if (registryKey == null)
{
Logger.Warn("autostart master registry key does not exist, attempting to create it");
registryKey = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
}
registryKey.SetValue("AutoDarkMode", '\u0022' + Helper.ExecutionPath + '\u0022');
registryKey.Close();
return true;
}
catch (Exception ex)
Expand Down

0 comments on commit 57f35ac

Please sign in to comment.