Created
June 16, 2019 04:56
-
-
Save secretGeek/fa0ea0039f0c5eaa7d122fe569fa2b44 to your computer and use it in GitHub Desktop.
Test if Windows is using a dark theme (from a Windows forms app, for example) (This is not battle-tested in the wild)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//using Microsoft.Win32 | |
public bool WindowsIsUsingDarkTheme() | |
{ | |
var keyName = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"; | |
var valueName = "AppsUseLightTheme"; | |
var value = Registry.GetValue(keyName, valueName, null); | |
if (value == null) | |
{ | |
return false; | |
} | |
if (int.TryParse(value.ToString(), out int result)){ | |
return result == 0; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment