From: Helix Graziani helix.graziani@hotmail.com
--- dlls/uxtheme/system.c | 18 ++++++++++++++++++ dlls/uxtheme/tests/system.c | 25 +++++++++++++++++++++++++ dlls/uxtheme/uxtheme.spec | 1 + 3 files changed, 44 insertions(+)
diff --git a/dlls/uxtheme/system.c b/dlls/uxtheme/system.c index 25f495d29f3..00642eb18ad 100644 --- a/dlls/uxtheme/system.c +++ b/dlls/uxtheme/system.c @@ -1256,3 +1256,21 @@ BOOL WINAPI ThemeHooksRemove(void) UnregisterUserApiHook(); return TRUE; } + +/********************************************************************** + * ShouldSystemUseDarkMode (UXTHEME.138) + * + * RETURNS + * whether or not the system should use dark mode + */ +BOOL WINAPI ShouldSystemUseDarkMode(void) +{ + HKEY hk = HKEY_CURRENT_USER; + DWORD systemUsesLightTheme; + + if (RegGetValueA(hk, "Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", + "AppsUseLightTheme", RRF_RT_REG_DWORD, NULL, &systemUsesLightTheme, NULL)) + systemUsesLightTheme = TRUE; /* when there is no theme selected, it is light */ + + return !systemUsesLightTheme; +} diff --git a/dlls/uxtheme/tests/system.c b/dlls/uxtheme/tests/system.c index 2e769625dab..5f340a17e6f 100644 --- a/dlls/uxtheme/tests/system.c +++ b/dlls/uxtheme/tests/system.c @@ -48,6 +48,7 @@ static HDC (WINAPI *pGetBufferedPaintTargetDC)(HPAINTBUFFER); static HRESULT (WINAPI *pGetBufferedPaintTargetRect)(HPAINTBUFFER, RECT *); static HRESULT (WINAPI *pGetThemeIntList)(HTHEME, int, int, int, INTLIST *); static HRESULT (WINAPI *pGetThemeTransitionDuration)(HTHEME, int, int, int, int, DWORD *); +static BOOL (WINAPI *pShouldSystemUseDarkMode)(void);
static LONG (WINAPI *pDisplayConfigGetDeviceInfo)(DISPLAYCONFIG_DEVICE_INFO_HEADER *); static LONG (WINAPI *pDisplayConfigSetDeviceInfo)(DISPLAYCONFIG_DEVICE_INFO_HEADER *); @@ -2597,6 +2598,29 @@ static void test_theme(void) DestroyWindow(hwnd); }
+static void test_ShouldUseDarkMode(void) +{ + HKEY hk = HKEY_CURRENT_USER; + DWORD systemUsesLightTheme; + LRESULT lr; + + pShouldSystemUseDarkMode = (void *)GetProcAddress(GetModuleHandleA("uxtheme.dll"), + MAKEINTRESOURCEA(138)); + if (!pShouldSystemUseDarkMode) + { + skip("ShouldSystemUseDarkMode was not found.\n"); + return; + } + + lr = RegGetValueA(hk, "Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", + "AppsUseLightTheme", RRF_RT_REG_DWORD, NULL, &systemUsesLightTheme, NULL); + ok(lr == 0 || lr == ERROR_FILE_NOT_FOUND, "RegGetValueA failed.\n"); + + if (lr == ERROR_FILE_NOT_FOUND) systemUsesLightTheme = 1; + + ok(pShouldSystemUseDarkMode() == !systemUsesLightTheme, "Expected registry key to match api.\n"); +} + START_TEST(system) { ULONG_PTR ctx_cookie; @@ -2622,6 +2646,7 @@ START_TEST(system) test_DrawThemeBackgroundEx(); test_GetThemeBackgroundRegion(); test_theme(); + test_ShouldUseDarkMode();
if (load_v6_module(&ctx_cookie, &ctx)) { diff --git a/dlls/uxtheme/uxtheme.spec b/dlls/uxtheme/uxtheme.spec index c60254b677d..a5bfb88c49a 100644 --- a/dlls/uxtheme/uxtheme.spec +++ b/dlls/uxtheme/uxtheme.spec @@ -42,6 +42,7 @@ 61 stdcall OpenThemeDataEx(ptr wstr long) 62 stub -noname ServerClearStockObjects 63 stub -noname MarkSelection +138 stdcall -noname ShouldSystemUseDarkMode()
# Standard functions @ stdcall BeginBufferedAnimation(ptr ptr ptr long ptr ptr ptr ptr)