https://git.reactos.org/?p=reactos.git;a=commitdiff;h=32669f6caa0ac0ea8674bb...
commit 32669f6caa0ac0ea8674bbe92be038fb4381a885 Author: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com AuthorDate: Sat Aug 26 16:46:51 2023 +0900 Commit: GitHub noreply@github.com CommitDate: Sat Aug 26 16:46:51 2023 +0900
[SHLWAPI][SHLWAPI_APITEST][SDK] Implement SHGetPerScreenResName (#5616)
CORE-9283 --- dll/win32/shlwapi/propbag.cpp | 22 ++++++++++++++++++++++ dll/win32/shlwapi/shlwapi.spec | 2 +- .../rostests/apitests/shlwapi/SHPropertyBag.cpp | 16 +++++++++++++++- sdk/include/reactos/shlwapi_undoc.h | 8 +++++--- 4 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/dll/win32/shlwapi/propbag.cpp b/dll/win32/shlwapi/propbag.cpp index 9faa250cd07..a1cbe199e6c 100644 --- a/dll/win32/shlwapi/propbag.cpp +++ b/dll/win32/shlwapi/propbag.cpp @@ -13,6 +13,7 @@ #include <atlsimpcoll.h> // for CSimpleMap #include <atlcomcli.h> // for CComVariant #include <atlconv.h> // for CA2W and CW2A +#include <strsafe.h> // for StringC... functions
WINE_DEFAULT_DEBUG_CHANNEL(shell);
@@ -1806,3 +1807,24 @@ EXTERN_C VOID FreeViewStatePropertyBagCache(VOID) g_pCachedBag.Release(); ::LeaveCriticalSection(&g_csBagCacheLock); } + +/************************************************************************** + * SHGetPerScreenResName (SHLWAPI.533) + * + * @see https://www.geoffchappell.com/studies/windows/shell/shlwapi/api/propbag/getp... + */ +INT WINAPI +SHGetPerScreenResName( + _Out_writes_(cchBuffer) LPWSTR pszBuffer, + _In_ INT cchBuffer, + _In_ DWORD dwReserved) +{ + if (dwReserved) + return 0; + + INT cxWidth = ::GetSystemMetrics(SM_CXFULLSCREEN); + INT cyHeight = ::GetSystemMetrics(SM_CYFULLSCREEN); + INT cMonitors = ::GetSystemMetrics(SM_CMONITORS); + StringCchPrintfW(pszBuffer, cchBuffer, L"%dx%d(%d)", cxWidth, cyHeight, cMonitors); + return lstrlenW(pszBuffer); +} diff --git a/dll/win32/shlwapi/shlwapi.spec b/dll/win32/shlwapi/shlwapi.spec index 434fb246046..35f1844bf91 100644 --- a/dll/win32/shlwapi/shlwapi.spec +++ b/dll/win32/shlwapi/shlwapi.spec @@ -530,7 +530,7 @@ 530 stdcall -noname SHPropertyBag_WriteInt(ptr wstr long) SHPropertyBag_WriteLONG 531 stdcall -noname SHPropertyBag_ReadStream(ptr wstr ptr) 532 stdcall -noname SHPropertyBag_WriteStream(ptr wstr ptr) -533 stub -noname SHGetPerScreenResName +533 stdcall -noname SHGetPerScreenResName(ptr long long) 534 stdcall -noname SHPropertyBag_ReadBOOL(ptr wstr ptr) 535 stdcall -noname SHPropertyBag_Delete(ptr wstr) 536 stdcall -stub -noname IUnknown_QueryServicePropertyBag(ptr long ptr ptr) diff --git a/modules/rostests/apitests/shlwapi/SHPropertyBag.cpp b/modules/rostests/apitests/shlwapi/SHPropertyBag.cpp index 57ec8881006..eae457b698e 100644 --- a/modules/rostests/apitests/shlwapi/SHPropertyBag.cpp +++ b/modules/rostests/apitests/shlwapi/SHPropertyBag.cpp @@ -11,6 +11,7 @@ #include <stdio.h> #include <shlwapi_undoc.h> #include <versionhelpers.h> +#include <strsafe.h>
#include <pseh/pseh2.h>
@@ -688,7 +689,7 @@ static void SHPropertyBag_SHSetIniStringW(void) DeleteFileW(szIniFile); }
-void SHPropertyBag_OnIniFile(void) +static void SHPropertyBag_OnIniFile(void) { WCHAR szIniFile[MAX_PATH], szValue[MAX_PATH]; HRESULT hr; @@ -823,6 +824,18 @@ void SHPropertyBag_OnIniFile(void) DeleteFileW(szIniFile); }
+static void SHPropertyBag_PerScreenRes(void) +{ + WCHAR szBuff1[64], szBuff2[64]; + StringCchPrintfW(szBuff1, _countof(szBuff1), L"%dx%d(%d)", + GetSystemMetrics(SM_CXFULLSCREEN), GetSystemMetrics(SM_CYFULLSCREEN), + GetSystemMetrics(SM_CMONITORS)); + + szBuff2[0] = UNICODE_NULL; + SHGetPerScreenResName(szBuff2, _countof(szBuff2), 0); + ok_wstr(szBuff1, szBuff2); +} + START_TEST(SHPropertyBag) { SHPropertyBag_ReadTest(); @@ -831,4 +844,5 @@ START_TEST(SHPropertyBag) SHPropertyBag_OnRegKey(); SHPropertyBag_SHSetIniStringW(); SHPropertyBag_OnIniFile(); + SHPropertyBag_PerScreenRes(); } diff --git a/sdk/include/reactos/shlwapi_undoc.h b/sdk/include/reactos/shlwapi_undoc.h index 37363db934b..d7f3790d897 100644 --- a/sdk/include/reactos/shlwapi_undoc.h +++ b/sdk/include/reactos/shlwapi_undoc.h @@ -108,9 +108,11 @@ HRESULT WINAPI SHPropertyBag_ReadRECTL(IPropertyBag *ppb, LPCWSTR pszPropName, R HRESULT WINAPI SHPropertyBag_ReadGUID(IPropertyBag *ppb, LPCWSTR pszPropName, GUID *pguid); HRESULT WINAPI SHPropertyBag_ReadStream(IPropertyBag *ppb, LPCWSTR pszPropName, IStream **ppStream);
-HRESULT WINAPI SHGetPerScreenResName(OUT LPWSTR lpResName, - IN INT cchResName, - IN DWORD dwReserved); +INT WINAPI +SHGetPerScreenResName( + _Out_writes_(cchBuffer) LPWSTR pszBuffer, + _In_ INT cchBuffer, + _In_ DWORD dwReserved);
HRESULT WINAPI SHPropertyBag_Delete(IPropertyBag *ppb, LPCWSTR pszPropName); HRESULT WINAPI SHPropertyBag_WriteBOOL(IPropertyBag *ppb, LPCWSTR pszPropName, BOOL bValue);