Skip to content

Commit

Permalink
Merge pull request #9 from geforce-hisa0904/feature/reg
Browse files Browse the repository at this point in the history
GetAppsUseTheme refactoring
  • Loading branch information
Kyome22 authored Aug 15, 2020
2 parents da97286 + 7f74999 commit f465e1c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions RunCat/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,17 @@ public RunCatApplicationContext()
private string GetAppsUseTheme()
{
string keyName = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize";
try
using (RegistryKey rKey = Registry.CurrentUser.OpenSubKey(keyName))
{
RegistryKey rKey = Registry.CurrentUser.OpenSubKey(keyName);
int theme = (int)rKey.GetValue("SystemUsesLightTheme");
rKey.Close();
object value;
if (rKey == null || (value = rKey.GetValue("SystemUsesLightTheme")) == null)
{
Console.WriteLine("Oh No! Couldn't get theme light/dark");
return "light";
}
int theme = (int)value;
return theme == 0 ? "dark" : "light";
}
catch (NullReferenceException)
{
Console.WriteLine("Oh No! Couldn't get theme light/dark");
return "light";
}
}

private void SetIcons()
Expand Down

0 comments on commit f465e1c

Please sign in to comment.