From 3615db9a005517a32ccbfcf3f296d298135c9ba2 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Mon, 25 Sep 2017 15:35:21 -0500 Subject: [PATCH] shell32: Set shelllink path when setting pidl. Signed-off-by: Vincent Povirk Signed-off-by: Alexandre Julliard --- dlls/shell32/shelllink.c | 13 +++++++++++++ dlls/shell32/tests/shelllink.c | 1 - 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c index 81d76d93d8a..ba334772144 100644 --- a/dlls/shell32/shelllink.c +++ b/dlls/shell32/shelllink.c @@ -1680,6 +1680,7 @@ static HRESULT WINAPI IShellLinkW_fnGetIDList(IShellLinkW * iface, LPITEMIDLIST static HRESULT WINAPI IShellLinkW_fnSetIDList(IShellLinkW * iface, LPCITEMIDLIST pidl) { IShellLinkImpl *This = impl_from_IShellLinkW(iface); + WCHAR path[MAX_PATH]; TRACE("(%p)->(pidl=%p)\n",This, pidl); @@ -1689,6 +1690,18 @@ static HRESULT WINAPI IShellLinkW_fnSetIDList(IShellLinkW * iface, LPCITEMIDLIST if( !This->pPidl ) return E_FAIL; + HeapFree( GetProcessHeap(), 0, This->sPath ); + This->sPath = NULL; + + if ( SHGetPathFromIDListW( pidl, path ) ) + { + This->sPath = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(path)+1)*sizeof(WCHAR)); + if (!This->sPath) + return E_OUTOFMEMORY; + + lstrcpyW(This->sPath, path); + } + This->bDirty = TRUE; return S_OK; diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c index ba73e9490d0..7326516a57a 100644 --- a/dlls/shell32/tests/shelllink.c +++ b/dlls/shell32/tests/shelllink.c @@ -239,7 +239,6 @@ static void test_get_set(void) strcpy(buffer,"garbage"); r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH); ok(r == S_OK, "GetPath failed (0x%08x)\n", r); - todo_wine ok(lstrcmpiA(buffer, mypath)==0, "GetPath returned '%s'\n", buffer); }