From: Jacek Caban Subject: [PATCH 3/3] shell32: Added SHGetPathFromIDListEx implementation. Message-Id: <94c8680d-085a-1405-ff04-82ca7bc36896@codeweavers.com> Date: Thu, 23 Feb 2017 15:42:49 +0100 Signed-off-by: Jacek Caban --- dlls/shell32/pidl.c | 19 +++++++++++++++---- dlls/shell32/shell32.spec | 1 + dlls/shell32/tests/shlfolder.c | 32 +++++++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/dlls/shell32/pidl.c b/dlls/shell32/pidl.c index c3a753a..72169d5 100644 --- a/dlls/shell32/pidl.c +++ b/dlls/shell32/pidl.c @@ -1245,16 +1245,27 @@ BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath) */ BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath) { + return SHGetPathFromIDListEx(pidl, pszPath, MAX_PATH, 0); +} + +/************************************************************************* + * SHGetPathFromIDListEx [SHELL32.@] + */ +BOOL WINAPI SHGetPathFromIDListEx(LPCITEMIDLIST pidl, WCHAR *path, DWORD path_size, GPFIDL_FLAGS flags) +{ HRESULT hr; LPCITEMIDLIST pidlLast; LPSHELLFOLDER psfFolder; DWORD dwAttributes; STRRET strret; - TRACE_(shell)("(pidl=%p,%p)\n", pidl, pszPath); + TRACE_(shell)("(pidl=%p,%p,%u,%x)\n", pidl, path, path_size, flags); pdump(pidl); - *pszPath = '\0'; + if (flags != GPFIDL_DEFAULT) + FIXME("Unsupported flags %x\n", flags); + + *path = '\0'; if (!pidl) return FALSE; @@ -1272,9 +1283,9 @@ BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath) IShellFolder_Release(psfFolder); if (FAILED(hr)) return FALSE; - hr = StrRetToBufW(&strret, pidlLast, pszPath, MAX_PATH); + hr = StrRetToBufW(&strret, pidlLast, path, path_size); - TRACE_(shell)("-- %s, 0x%08x\n",debugstr_w(pszPath), hr); + TRACE_(shell)("-- %s, 0x%08x\n",debugstr_w(path), hr); return SUCCEEDED(hr); } diff --git a/dlls/shell32/shell32.spec b/dlls/shell32/shell32.spec index 0f26a34..3f9f52a 100644 --- a/dlls/shell32/shell32.spec +++ b/dlls/shell32/shell32.spec @@ -390,6 +390,7 @@ @ stdcall SHGetNewLinkInfo(str str ptr ptr long) SHGetNewLinkInfoA @ stdcall SHGetPathFromIDList(ptr ptr) SHGetPathFromIDListA @ stdcall SHGetPathFromIDListA(ptr ptr) +@ stdcall SHGetPathFromIDListEx(ptr ptr long long) @ stdcall SHGetPathFromIDListW(ptr ptr) @ stdcall SHGetPropertyStoreForWindow(long ptr ptr) @ stdcall SHGetPropertyStoreFromParsingName(wstr ptr long ptr ptr) diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c index 90418bd..759cce6 100644 --- a/dlls/shell32/tests/shlfolder.c +++ b/dlls/shell32/tests/shlfolder.c @@ -76,6 +76,7 @@ static HRESULT (WINAPI *pSHCreateDefaultContextMenu)(const DEFCONTEXTMENU*,REFII static HRESULT (WINAPI *pSHCreateShellFolderView)(const SFV_CREATE *pcsfv, IShellView **ppsv); static HRESULT (WINAPI *pSHCreateShellFolderViewEx)(LPCSFV psvcbi, IShellView **ppv); static HRESULT (WINAPI *pSHILCreateFromPath)(LPCWSTR, LPITEMIDLIST *,DWORD*); +static BOOL (WINAPI *pSHGetPathFromIDListEx)(PCIDLIST_ABSOLUTE,WCHAR*,DWORD,GPFIDL_FLAGS); static WCHAR *make_wstr(const char *str) { @@ -135,6 +136,7 @@ static void init_function_pointers(void) MAKEFUNC(SHCreateDefaultContextMenu); MAKEFUNC(SHCreateShellFolderView); MAKEFUNC(SHCreateShellFolderViewEx); + MAKEFUNC(SHGetPathFromIDListEx); #undef MAKEFUNC #define MAKEFUNC_ORD(f, ord) (p##f = (void*)GetProcAddress(hmod, (LPSTR)(ord))) @@ -1347,10 +1349,34 @@ static void test_SHGetPathFromIDList(void) result = pSHGetPathFromIDListW(pidlTestFile, wszPath); ok(result, "SHGetPathFromIDListW failed! Last error: %u\n", GetLastError()); - IMalloc_Free(ppM, pidlTestFile); - if (!result) return; ok(0 == lstrcmpW(wszFileName, wszPath), "SHGetPathFromIDListW returned incorrect path for file placed on desktop\n"); + if (pSHGetPathFromIDListEx) + { + result = pSHGetPathFromIDListEx(pidlEmpty, wszPath, MAX_PATH, SFGAO_FILESYSTEM); + ok(result, "SHGetPathFromIDListEx failed: %u\n", GetLastError()); + ok(!lstrcmpiW(wszDesktop, wszPath), "Unexpected SHGetPathFromIDListEx result %s, expected %s\n", + wine_dbgstr_w(wszPath), wine_dbgstr_w(wszDesktop)); + + result = pSHGetPathFromIDListEx(pidlTestFile, wszPath, MAX_PATH, SFGAO_FILESYSTEM); + ok(result, "SHGetPathFromIDListEx failed: %u\n", GetLastError()); + ok(!lstrcmpiW(wszFileName, wszPath), "Unexpected SHGetPathFromIDListEx result %s, expected %s\n", + wine_dbgstr_w(wszPath), wine_dbgstr_w(wszFileName)); + + SetLastError(0xdeadbeef); + memset(wszPath, 0x55, sizeof(wszPath)); + result = pSHGetPathFromIDListEx(pidlTestFile, wszPath, 5, SFGAO_FILESYSTEM); + ok(!result, "SHGetPathFromIDListEx returned: %x(%u)\n", result, GetLastError()); + + SetLastError(0xdeadbeef); + memset(wszPath, 0x55, sizeof(wszPath)); + result = pSHGetPathFromIDListEx(pidlEmpty, wszPath, 5, SFGAO_FILESYSTEM); + ok(!result, "SHGetPathFromIDListEx returned: %x(%u)\n", result, GetLastError()); + } + else + win_skip("SHGetPathFromIDListEx not available\n"); + + IMalloc_Free(ppM, pidlTestFile); /* Test if we can get the path from the start menu "program files" PIDL. */ hr = pSHGetSpecialFolderLocation(NULL, CSIDL_PROGRAM_FILES, &pidlPrograms); @@ -1358,7 +1384,7 @@ static void test_SHGetPathFromIDList(void) SetLastError(0xdeadbeef); result = pSHGetPathFromIDListW(pidlPrograms, wszPath); - IMalloc_Free(ppM, pidlPrograms); + IMalloc_Free(ppM, pidlPrograms); ok(result, "SHGetPathFromIDListW failed\n"); }