private static void ConfigureAutoCADThemeAsWindowsTheme()
{
var COLORTHEME = (short)Application.GetSystemVariable("COLORTHEME");
const string RegistryKeyPath = @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";
const string RegistryValueName = "AppsUseLightTheme";
// 这里也可能是LocalMachine(HKEY_LOCAL_MACHINE)
// see "https://www.addictivetips.com/windows-tips/how-to-enable-the-dark-theme-in-windows-10/"
object? registryValueObject = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(RegistryKeyPath)?.GetValue(RegistryValueName);
bool curSysThemeIsBlack;
if (registryValueObject is null) curSysThemeIsBlack = false;
curSysThemeIsBlack = (int)registryValueObject <= 0;
if (curSysThemeIsBlack)
{
if (COLORTHEME != 0)
Application.SetSystemVariable("COLORTHEME", 0);
}
else
{
if (COLORTHEME != 1)
Application.SetSystemVariable("COLORTHEME", 1);
}
}