shell32: Add support for find data in IShellLink:GetPath.
Signed-off-by: Vincent Povirk <vincent@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
aa37e696cb
commit
8a46b9e5d1
|
@ -1270,7 +1270,39 @@ static HRESULT WINAPI IShellLinkA_fnGetPath(IShellLinkA *iface, LPSTR pszFile, I
|
|||
else
|
||||
res = S_FALSE;
|
||||
|
||||
if (pfd) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", This);
|
||||
if (pfd)
|
||||
{
|
||||
memset(pfd, 0, sizeof(*pfd));
|
||||
|
||||
if (res == S_OK)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
WIN32_FILE_ATTRIBUTE_DATA fad;
|
||||
|
||||
WideCharToMultiByte(CP_ACP, 0, This->sPath, -1, path, MAX_PATH, NULL, NULL);
|
||||
|
||||
if (GetFileAttributesExW(This->sPath, GetFileExInfoStandard, &fad))
|
||||
{
|
||||
pfd->dwFileAttributes = fad.dwFileAttributes;
|
||||
pfd->ftCreationTime = fad.ftCreationTime;
|
||||
pfd->ftLastAccessTime = fad.ftLastAccessTime;
|
||||
pfd->ftLastWriteTime = fad.ftLastWriteTime;
|
||||
pfd->nFileSizeHigh = fad.nFileSizeHigh;
|
||||
pfd->nFileSizeLow = fad.nFileSizeLow;
|
||||
}
|
||||
|
||||
lstrcpyA(pfd->cFileName, PathFindFileNameA(path));
|
||||
|
||||
if (GetShortPathNameA(path, path, MAX_PATH))
|
||||
{
|
||||
lstrcpyA(pfd->cAlternateFileName, PathFindFileNameA(path));
|
||||
}
|
||||
}
|
||||
|
||||
TRACE("attr 0x%08x size 0x%08x%08x name %s shortname %s\n", pfd->dwFileAttributes,
|
||||
pfd->nFileSizeHigh, pfd->nFileSizeLow, wine_dbgstr_a(pfd->cFileName),
|
||||
wine_dbgstr_a(pfd->cAlternateFileName));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -1657,7 +1689,37 @@ static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile,
|
|||
else
|
||||
res = S_FALSE;
|
||||
|
||||
if (pfd) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", This);
|
||||
if (pfd)
|
||||
{
|
||||
memset(pfd, 0, sizeof(*pfd));
|
||||
|
||||
if (res == S_OK)
|
||||
{
|
||||
WCHAR path[MAX_PATH];
|
||||
WIN32_FILE_ATTRIBUTE_DATA fad;
|
||||
|
||||
if (GetFileAttributesExW(This->sPath, GetFileExInfoStandard, &fad))
|
||||
{
|
||||
pfd->dwFileAttributes = fad.dwFileAttributes;
|
||||
pfd->ftCreationTime = fad.ftCreationTime;
|
||||
pfd->ftLastAccessTime = fad.ftLastAccessTime;
|
||||
pfd->ftLastWriteTime = fad.ftLastWriteTime;
|
||||
pfd->nFileSizeHigh = fad.nFileSizeHigh;
|
||||
pfd->nFileSizeLow = fad.nFileSizeLow;
|
||||
}
|
||||
|
||||
lstrcpyW(pfd->cFileName, PathFindFileNameW(This->sPath));
|
||||
|
||||
if (GetShortPathNameW(This->sPath, path, MAX_PATH))
|
||||
{
|
||||
lstrcpyW(pfd->cAlternateFileName, PathFindFileNameW(path));
|
||||
}
|
||||
}
|
||||
|
||||
TRACE("attr 0x%08x size 0x%08x%08x name %s shortname %s\n", pfd->dwFileAttributes,
|
||||
pfd->nFileSizeHigh, pfd->nFileSizeLow, wine_dbgstr_w(pfd->cFileName),
|
||||
wine_dbgstr_w(pfd->cAlternateFileName));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -105,6 +105,7 @@ static void test_get_set(void)
|
|||
IShellLinkW *slW = NULL;
|
||||
char mypath[MAX_PATH];
|
||||
char buffer[INFOTIPSIZE];
|
||||
WIN32_FIND_DATAA finddata;
|
||||
LPITEMIDLIST pidl, tmp_pidl;
|
||||
const char * str;
|
||||
int i;
|
||||
|
@ -160,6 +161,14 @@ static void test_get_set(void)
|
|||
ok(r == S_FALSE || broken(r == S_OK) /* NT4/W2K */, "GetPath failed (0x%08x)\n", r);
|
||||
ok(*buffer=='\0', "GetPath returned '%s'\n", buffer);
|
||||
|
||||
strcpy(buffer,"garbage");
|
||||
memset(&finddata, 0xaa, sizeof(finddata));
|
||||
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), &finddata, SLGP_RAWPATH);
|
||||
ok(r == S_FALSE || broken(r == S_OK) /* NT4/W2K */, "GetPath failed (0x%08x)\n", r);
|
||||
ok(*buffer=='\0', "GetPath returned '%s'\n", buffer);
|
||||
ok(finddata.dwFileAttributes == 0, "unexpected attributes %x\n", finddata.dwFileAttributes);
|
||||
ok(finddata.cFileName[0] == 0, "unexpected filename '%s'\n", finddata.cFileName);
|
||||
|
||||
CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IShellLinkW, (LPVOID*)&slW);
|
||||
if (!slW /* Win9x */ || !pGetLongPathNameA /* NT4 */)
|
||||
|
@ -191,6 +200,14 @@ static void test_get_set(void)
|
|||
ok(r == S_OK, "GetPath failed (0x%08x)\n", r);
|
||||
ok(lstrcmpiA(buffer,str)==0, "GetPath returned '%s'\n", buffer);
|
||||
|
||||
strcpy(buffer,"garbage");
|
||||
memset(&finddata, 0xaa, sizeof(finddata));
|
||||
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), &finddata, SLGP_RAWPATH);
|
||||
ok(r == S_OK, "GetPath failed (0x%08x)\n", r);
|
||||
ok(lstrcmpiA(buffer,str)==0, "GetPath returned '%s'\n", buffer);
|
||||
ok(finddata.dwFileAttributes == 0, "unexpected attributes %x\n", finddata.dwFileAttributes);
|
||||
ok(lstrcmpiA(finddata.cFileName, "file") == 0, "unexpected filename '%s'\n", finddata.cFileName);
|
||||
|
||||
/* Get some real path to play with */
|
||||
GetWindowsDirectoryA( mypath, sizeof(mypath)-12 );
|
||||
strcat(mypath, "\\regedit.exe");
|
||||
|
@ -241,6 +258,14 @@ static void test_get_set(void)
|
|||
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
|
||||
ok(r == S_OK, "GetPath failed (0x%08x)\n", r);
|
||||
ok(lstrcmpiA(buffer, mypath)==0, "GetPath returned '%s'\n", buffer);
|
||||
|
||||
strcpy(buffer,"garbage");
|
||||
memset(&finddata, 0xaa, sizeof(finddata));
|
||||
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), &finddata, SLGP_RAWPATH);
|
||||
ok(r == S_OK, "GetPath failed (0x%08x)\n", r);
|
||||
ok(lstrcmpiA(buffer, mypath)==0, "GetPath returned '%s'\n", buffer);
|
||||
ok(finddata.dwFileAttributes != 0, "unexpected attributes %x\n", finddata.dwFileAttributes);
|
||||
ok(lstrcmpiA(finddata.cFileName, "regedit.exe") == 0, "unexpected filename '%s'\n", finddata.cFileName);
|
||||
}
|
||||
|
||||
if (pSHGetFolderLocation)
|
||||
|
@ -258,6 +283,14 @@ static void test_get_set(void)
|
|||
ok(r == S_FALSE, "GetPath failed (0x%08x)\n", r);
|
||||
ok(buffer[0] == 0, "GetPath returned '%s'\n", buffer);
|
||||
|
||||
strcpy(buffer,"garbage");
|
||||
memset(&finddata, 0xaa, sizeof(finddata));
|
||||
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), &finddata, SLGP_RAWPATH);
|
||||
ok(r == S_FALSE, "GetPath failed (0x%08x)\n", r);
|
||||
ok(buffer[0] == 0, "GetPath returned '%s'\n", buffer);
|
||||
ok(finddata.dwFileAttributes == 0, "unexpected attributes %x\n", finddata.dwFileAttributes);
|
||||
ok(finddata.cFileName[0] == 0, "unexpected filename '%s'\n", finddata.cFileName);
|
||||
|
||||
pILFree(pidl_controls);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue