[SHLWAPI][SHLWAPI_APITEST] Fix SHGetPerScreenResName (#5701)
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Tue, 19 Sep 2023 02:02:59 +0000 (11:02 +0900)
committerGitHub <noreply@github.com>
Tue, 19 Sep 2023 02:02:59 +0000 (11:02 +0900)
Use HORZRES and VERTRES instead of SM_CXFULLSCREEN and SM_CYFULLSCREEN.
CORE-9283

dll/win32/shlwapi/propbag.cpp
modules/rostests/apitests/shlwapi/CMakeLists.txt
modules/rostests/apitests/shlwapi/SHPropertyBag.cpp

index c355647..98d2bc4 100644 (file)
@@ -1947,9 +1947,12 @@ SHGetPerScreenResName(
     if (dwReserved)
         return 0;
 
-    INT cxWidth = ::GetSystemMetrics(SM_CXFULLSCREEN);
-    INT cyHeight = ::GetSystemMetrics(SM_CYFULLSCREEN);
+    HDC hDC = ::GetDC(NULL);
+    INT cxWidth = ::GetDeviceCaps(hDC, HORZRES);
+    INT cyHeight = ::GetDeviceCaps(hDC, VERTRES);
     INT cMonitors = ::GetSystemMetrics(SM_CMONITORS);
+    ::ReleaseDC(NULL, hDC);
+
     StringCchPrintfW(pszBuffer, cchBuffer, L"%dx%d(%d)", cxWidth, cyHeight, cMonitors);
     return lstrlenW(pszBuffer);
 }
index d5c4d32..8eeb818 100644 (file)
@@ -25,6 +25,6 @@ add_rc_deps(testdata.rc ${CMAKE_CURRENT_BINARY_DIR}/shlwapi_resource_dll/shlwapi
 add_executable(shlwapi_apitest ${SOURCE})
 set_module_type(shlwapi_apitest win32cui)
 target_link_libraries(shlwapi_apitest ${PSEH_LIB} uuid)
-add_importlibs(shlwapi_apitest shlwapi oleaut32 ole32 user32 advapi32 msvcrt kernel32)
+add_importlibs(shlwapi_apitest shlwapi oleaut32 ole32 user32 gdi32 advapi32 msvcrt kernel32)
 add_dependencies(shlwapi_apitest shlwapi_resource_dll)
 add_rostests_file(TARGET shlwapi_apitest)
index eae457b..c155693 100644 (file)
@@ -826,10 +826,14 @@ static void SHPropertyBag_OnIniFile(void)
 
 static void SHPropertyBag_PerScreenRes(void)
 {
+    HDC hDC = GetDC(NULL);
+    INT cxWidth = GetDeviceCaps(hDC, HORZRES);
+    INT cyHeight = GetDeviceCaps(hDC, VERTRES);
+    INT cMonitors = GetSystemMetrics(SM_CMONITORS);
+    ReleaseDC(NULL, hDC);
+
     WCHAR szBuff1[64], szBuff2[64];
-    StringCchPrintfW(szBuff1, _countof(szBuff1), L"%dx%d(%d)",
-                     GetSystemMetrics(SM_CXFULLSCREEN), GetSystemMetrics(SM_CYFULLSCREEN),
-                     GetSystemMetrics(SM_CMONITORS));
+    StringCchPrintfW(szBuff1, _countof(szBuff1), L"%dx%d(%d)", cxWidth, cyHeight, cMonitors);
 
     szBuff2[0] = UNICODE_NULL;
     SHGetPerScreenResName(szBuff2, _countof(szBuff2), 0);