[SHLWAPI][SHLWAPI_APITEST] Fix SHGetPerScreenResName (#5701)

Use HORZRES and VERTRES instead of SM_CXFULLSCREEN and SM_CYFULLSCREEN.
CORE-9283
This commit is contained in:
Katayama Hirofumi MZ 2023-09-19 11:02:59 +09:00 committed by GitHub
parent 08cc45eef9
commit ff5ccb5948
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 6 deletions

View 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);
}

View 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)

View 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);