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 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