shell32: IShellLink::GetPath returns S_FALSE if there's no path.

Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Vincent Povirk 2017-09-25 15:35:20 -05:00 committed by Alexandre Julliard
parent a796bcaa7f
commit 94378704f8
2 changed files with 11 additions and 5 deletions

View File

@ -1254,6 +1254,7 @@ static HRESULT WINAPI IShellLinkA_fnGetPath(IShellLinkA *iface, LPSTR pszFile, I
WIN32_FIND_DATAA *pfd, DWORD fFlags)
{
IShellLinkImpl *This = impl_from_IShellLinkA(iface);
HRESULT res = S_OK;
TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
This, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(This->sPath));
@ -1263,13 +1264,15 @@ static HRESULT WINAPI IShellLinkA_fnGetPath(IShellLinkA *iface, LPSTR pszFile, I
if (cchMaxPath)
pszFile[0] = 0;
if (This->sPath)
if (This->sPath && This->sPath[0])
WideCharToMultiByte( CP_ACP, 0, This->sPath, -1,
pszFile, cchMaxPath, NULL, NULL);
else
res = S_FALSE;
if (pfd) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", This);
return S_OK;
return res;
}
static HRESULT WINAPI IShellLinkA_fnGetIDList(IShellLinkA *iface, LPITEMIDLIST *ppidl)
@ -1639,6 +1642,7 @@ static ULONG WINAPI IShellLinkW_fnRelease(IShellLinkW * iface)
static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAW *pfd, DWORD fFlags)
{
IShellLinkImpl *This = impl_from_IShellLinkW(iface);
HRESULT res = S_OK;
TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
This, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(This->sPath));
@ -1650,10 +1654,12 @@ static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile,
pszFile[0] = 0;
if (This->sPath)
lstrcpynW( pszFile, This->sPath, cchMaxPath );
else
res = S_FALSE;
if (pfd) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", This);
return S_OK;
return res;
}
static HRESULT WINAPI IShellLinkW_fnGetIDList(IShellLinkW * iface, LPITEMIDLIST * ppidl)

View File

@ -156,7 +156,7 @@ static void test_get_set(void)
/* Test Getting / Setting the path */
strcpy(buffer,"garbage");
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
todo_wine ok(r == S_FALSE || broken(r == S_OK) /* NT4/W2K */, "GetPath failed (0x%08x)\n", r);
ok(r == S_FALSE || broken(r == S_OK) /* NT4/W2K */, "GetPath failed (0x%08x)\n", r);
ok(*buffer=='\0', "GetPath returned '%s'\n", buffer);
CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
@ -177,7 +177,7 @@ static void test_get_set(void)
strcpy(buffer,"garbage");
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
todo_wine ok(r == S_FALSE, "GetPath failed (0x%08x)\n", r);
ok(r == S_FALSE, "GetPath failed (0x%08x)\n", r);
ok(*buffer=='\0', "GetPath returned '%s'\n", buffer);
/* Win98 returns S_FALSE, but WinXP returns S_OK */