Skip to content

Instantly share code, notes, and snippets.

@secretGeek
Created June 16, 2019 04:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save secretGeek/fa0ea0039f0c5eaa7d122fe569fa2b44 to your computer and use it in GitHub Desktop.
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)
//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