Files
better-genshin-impact/Build/MicaSetup/Design/Themes/WindowsThemeHelper.cs

22 lines
612 B
C#

using Microsoft.Win32;
namespace MicaSetup.Design.Controls;
public static class WindowsThemeHelper
{
public static WindowsTheme GetCurrentWindowsTheme()
{
using RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize");
object? registryValueObject = key?.GetValue("AppsUseLightTheme");
if (registryValueObject == null)
{
return WindowsTheme.Light;
}
var registryValue = (int)registryValueObject;
return registryValue > 0 ? WindowsTheme.Light : WindowsTheme.Dark;
}
}