From: Alex Henrie alexhenrie24@gmail.com
The tests show that the first argument must not be null, that the handle returned via the fourth argument is not an HTHEME, and that that handle can be passed to CloseThemeFile without error. --- dlls/uxtheme/tests/system.c | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
diff --git a/dlls/uxtheme/tests/system.c b/dlls/uxtheme/tests/system.c index c79a6c85a35..36740fe2664 100644 --- a/dlls/uxtheme/tests/system.c +++ b/dlls/uxtheme/tests/system.c @@ -38,6 +38,8 @@
static HTHEME (WINAPI * pOpenThemeDataEx)(HWND, LPCWSTR, DWORD); static HTHEME (WINAPI *pOpenThemeDataForDpi)(HWND, LPCWSTR, UINT); +static HRESULT (WINAPI *pOpenThemeFile)(const WCHAR *, const WCHAR *, const WCHAR *, HANDLE, DWORD); +static HRESULT (WINAPI *pCloseThemeFile)(HANDLE); static HPAINTBUFFER (WINAPI *pBeginBufferedPaint)(HDC, const RECT *, BP_BUFFERFORMAT, BP_PAINTPARAMS *, HDC *); static HRESULT (WINAPI *pBufferedPaintClear)(HPAINTBUFFER, const RECT *); static HRESULT (WINAPI *pDrawThemeBackgroundEx)(HTHEME, HDC, int, int, const RECT *, const DTBGOPTS *); @@ -76,6 +78,8 @@ static void init_funcs(void) HMODULE gdi32 = GetModuleHandleA("gdi32.dll"); HMODULE uxtheme = GetModuleHandleA("uxtheme.dll");
+ pOpenThemeFile = (void *)GetProcAddress(uxtheme, MAKEINTRESOURCEA(2)); + pCloseThemeFile = (void *)GetProcAddress(uxtheme, MAKEINTRESOURCEA(3)); pShouldSystemUseDarkMode = (void *)GetProcAddress(uxtheme, MAKEINTRESOURCEA(138)); pShouldAppsUseDarkMode = (void *)GetProcAddress(uxtheme, MAKEINTRESOURCEA(132));
@@ -874,6 +878,48 @@ static void test_CloseThemeData(void) ok(hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08lx\n", hRes); }
+static void test_OpenThemeFile(void) +{ + WCHAR currentThemePath[MAX_PATH]; + DWORD pathSize = sizeof(currentThemePath); + HANDLE htf; + LSTATUS ls; + HRESULT hr; + SIZE partSize; + + if (!pOpenThemeFile) + { + win_skip("OpenThemeFile is unavailable.\n"); + return; + } + + ls = RegGetValueW(HKEY_CURRENT_USER, + L"Software\Microsoft\Windows\CurrentVersion\ThemeManager", L"DllName", + RRF_RT_REG_SZ, NULL, currentThemePath, &pathSize); + if (ls == ERROR_FILE_NOT_FOUND) + { + win_skip("DllName registry value not found.\n"); + return; + } + ok(ls == ERROR_SUCCESS, "RegGetValueW failed: %ld\n", ls); + + htf = (void *)0xdeadbeef; + hr = pOpenThemeFile(NULL, NULL, NULL, &htf, 0); + todo_wine ok(hr == E_POINTER, "Expected E_POINTER, got 0x%08lx\n", hr); + ok(!htf, "Expected NULL, got %p\n", htf); + + htf = (void *)0xdeadbeef; + hr = pOpenThemeFile(currentThemePath, NULL, NULL, &htf, 0); + ok(hr == S_OK, "Expected S_OK, got 0x%08lx\n", hr); + ok(htf != (void *)0xdeadbeef && htf != NULL && htf != INVALID_HANDLE_VALUE, "got %p\n", htf); + + hr = GetThemePartSize(htf, NULL, BP_CHECKBOX, CBS_CHECKEDNORMAL, NULL, TS_DRAW, &partSize); + todo_wine ok(hr == E_HANDLE, "Expected E_HANDLE, got 0x%08lx\n", hr); + + hr = pCloseThemeFile(htf); + ok(hr == S_OK, "Expected S_OK, got 0x%08lx\n", hr); +} + static void test_buffer_dc_props(HDC hdc, const RECT *rect) { static const XFORM ident = { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f }; @@ -2704,6 +2750,7 @@ START_TEST(system) test_OpenThemeData(); test_OpenThemeDataEx(); test_OpenThemeDataForDpi(); + test_OpenThemeFile(); test_GetCurrentThemeName(); test_GetThemePartSize(); test_CloseThemeData();