/*** 当前操作系统的应用主题 Austin Liu 刘恒辉 Project Manager and Software Designer E-Mail: lzhdim@163.com Blog: http://lzhdim.cnblogs.com Date: 2024-01-15 15:18:00 ***/ namespace Lzhdim.LPF.Utility { using Microsoft.Win32; /// <summary> /// 当前操作系统的应用主题 /// </summary> public sealed class AppsUseLightThemeUtil { /// <summary> /// 是否是深色模式 /// </summary> /// <returns></returns> public static bool IsDarkModeEnabled() { const string RegistryKeyPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"; const string RegistryValueName = "AppsUseLightTheme"; object registryValueObject = Registry.CurrentUser.OpenSubKey(RegistryKeyPath)?.GetValue(RegistryValueName); if (registryValueObject is null) return false; return (int)registryValueObject == 0; // 0 表示深色模式,1 表示浅色模式 } } }
![]() |
Austin Liu 刘恒辉
Project Manager and Software Designer E-Mail:lzhdim@163.com Blog:https://lzhdim.cnblogs.com 欢迎收藏和转载此博客中的博文,但是请注明出处,给笔者一个与大家交流的空间。谢谢大家。 |




浙公网安备 33010602011771号