Favicon

Windows theme color

Peponi1/14/20251m

C#
Win32RegistryThemeColor

1. Introduction

themecolormode

상기 그림과 같이, 윈도우에는 색 모드를 설정할 수 있는 옵션이 있다. 다음은 레지스트리 값을 읽어 윈도우 색 모드 설정값을 얻어오는 방법이다.

설명
-1레지스트리 미발견
0다크
1라이트

2. Code

using Microsoft.Win32;
 
namespace WindowTheme
{
    public static class WindowThemeColor
    {
        public static bool IsDarkTheme()
        {
            // 1은 라이트, 0은 다크, -1은 못찾았음
            int res = (int)Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", -1);
            return res == 0;
        }
    }
}

3. 참조 자료