From 6162364577e2946a163e647c3c31d91fb270a06c Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Tue, 13 Apr 2021 20:02:54 +0200 Subject: [PATCH] [BUG] NullReferenceException when regedit key missing for darkmode (#148), version 1.0.17.9 --- Config/Config.cs | 14 +++++++++++++- Properties/AssemblyInfo.cs | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Config/Config.cs b/Config/Config.cs index d3970c6..9388582 100644 --- a/Config/Config.cs +++ b/Config/Config.cs @@ -127,8 +127,20 @@ namespace SystemTrayMenu private static bool IsDarkModeActive() { // Check: AppsUseLightTheme (REG_DWORD) + bool isDarkModeActive = false; + object registryValueAppsUseLightTheme = Registry.GetValue( + "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", + "AppsUseLightTheme", + 1); + // 0 = Dark mode, 1 = Light mode - return Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", "AppsUseLightTheme", 1).ToString() == "0"; + if (registryValueAppsUseLightTheme != null && + registryValueAppsUseLightTheme.ToString() == "0") + { + isDarkModeActive = true; + } + + return isDarkModeActive; } } } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index e4f9ed6..bae796e 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -39,5 +39,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.17.8")] -[assembly: AssemblyFileVersion("1.0.17.8")] +[assembly: AssemblyVersion("1.0.17.9")] +[assembly: AssemblyFileVersion("1.0.17.9")]