[PATCH] shell32: Improve semi-stub SHGetStockIconInfo to return an iconhandle if SHGSI_ICON flag is set
Louis Lenders
xerox.xerox2000x at gmail.com
Wed Sep 26 09:34:11 CDT 2018
Fix for bug https://bugs.winehq.org/show_bug.cgi?id=45868
Signed-off-by: Louis Lenders <xerox.xerox2000x at gmail.com>
---
dlls/shell32/iconcache.c | 22 +++++++++++++++++-----
dlls/shell32/tests/shelllink.c | 8 ++++++++
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/dlls/shell32/iconcache.c b/dlls/shell32/iconcache.c
index 6107e0c33b..73617761a5 100644
--- a/dlls/shell32/iconcache.c
+++ b/dlls/shell32/iconcache.c
@@ -1004,7 +1004,9 @@ INT WINAPI SHGetIconOverlayIndexW(LPCWSTR pszIconPath, INT iIconIndex)
*/
HRESULT WINAPI SHGetStockIconInfo(SHSTOCKICONID id, UINT flags, SHSTOCKICONINFO *sii)
{
- static const WCHAR shell32dll[] = {'\\','s','h','e','l','l','3','2','.','d','l','l',0};
+ static const WCHAR shell32dllW[] = {'s','h','e','l','l','3','2','.','d','l','l',0};
+ static const WCHAR slashW[] = {'\\',0};
+ HMODULE hmod;
FIXME("(%d, 0x%x, %p) semi-stub\n", id, flags, sii);
if ((id < 0) || (id >= SIID_MAX_ICONS) || !sii || (sii->cbSize != sizeof(SHSTOCKICONINFO))) {
@@ -1015,14 +1017,24 @@ HRESULT WINAPI SHGetStockIconInfo(SHSTOCKICONID id, UINT flags, SHSTOCKICONINFO
/* no icons defined: use default */
sii->iIcon = -IDI_SHELL_FILE;
- lstrcatW(sii->szPath, shell32dll);
-
- if (flags)
- FIXME("flags 0x%x not implemented\n", flags);
+ lstrcatW(sii->szPath, slashW);
+ lstrcatW(sii->szPath, shell32dllW);
sii->hIcon = NULL;
sii->iSysImageIndex = -1;
+ if (flags & SHGSI_ICON)
+ {
+ hmod = GetModuleHandleW(shell32dllW);
+ if (hmod)
+ sii->hIcon = LoadIconW(hmod, MAKEINTRESOURCEW(IDI_SHELL_FILE));
+
+ if (!sii->hIcon)
+ ERR("failed to get an icon handle");
+ }
+ else
+ FIXME("flags 0x%x not implemented\n", flags);
+
TRACE("%3d: returning %s (%d)\n", id, debugstr_w(sii->szPath), sii->iIcon);
return S_OK;
diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c
index 65e9a6dd55..e0068978ec 100644
--- a/dlls/shell32/tests/shelllink.c
+++ b/dlls/shell32/tests/shelllink.c
@@ -1112,6 +1112,14 @@ static void test_SHGetStockIconInfo(void)
/* there is a NULL check for the struct */
hr = pSHGetStockIconInfo(SIID_FOLDER, SHGSI_ICONLOCATION, NULL);
ok(hr == E_INVALIDARG, "NULL: got 0x%x\n", hr);
+
+ memset(buffer, '#', sizeof(buffer));
+ sii->cbSize = sizeof(SHSTOCKICONINFO);
+ hr = pSHGetStockIconInfo(SIID_SHIELD, SHGSI_ICON | SHGSI_SMALLICON, sii);
+ ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr);
+ ok(sii->hIcon != NULL, "got NULL, expected an icon handle\n");
+ ok(sii->iSysImageIndex == -1, "got %d (expected -1)\n", sii->iSysImageIndex);
+ ok(DestroyIcon(sii->hIcon), "DestroyIcon failed\n");
}
static void test_SHExtractIcons(void)
--
2.17.1
More information about the wine-devel
mailing list