Commit aa3165fc authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

shell32: Add proper support for SHGetFileInfo(SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES).

parent 5c5933f6
......@@ -356,14 +356,6 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
(flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
return FALSE;
if ( (flags & SHGFI_USEFILEATTRIBUTES) &&
(flags & (SHGFI_ICONLOCATION | SHGFI_ICON | SHGFI_SYSICONINDEX)) )
{
FIXME("This combination of flags is not supported yet\n");
/* And it would cause a crash, so return false instead */
return FALSE;
}
/* windows initializes these values regardless of the flags */
if (psfi != NULL)
{
......@@ -519,6 +511,39 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
{
UINT uDummy,uFlags;
if (flags & SHGFI_USEFILEATTRIBUTES)
{
if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
lstrcpyW(psfi->szDisplayName, swShell32Name);
psfi->iIcon = -IDI_SHELL_FOLDER;
}
else
{
WCHAR* szExt;
static const WCHAR p1W[] = {'%','1',0};
WCHAR sTemp [MAX_PATH];
szExt = (LPWSTR) PathFindExtensionW(szFullPath);
TRACE("szExt=%s\n", debugstr_w(szExt));
if ( szExt &&
HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) &&
HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &psfi->iIcon))
{
if (lstrcmpW(p1W, sTemp))
strcpyW(psfi->szDisplayName, sTemp);
else
{
/* the icon is in the file */
strcpyW(psfi->szDisplayName, szFullPath);
}
}
else
ret = FALSE;
}
}
else
{
hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1,
(LPCITEMIDLIST*)&pidlLast, &IID_IExtractIconW,
&uDummy, (LPVOID*)&pei);
......@@ -526,16 +551,18 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
{
hr = IExtractIconW_GetIconLocation(pei, uGilFlags,
szLocation, MAX_PATH, &iIndex, &uFlags);
psfi->iIcon = iIndex;
if (!(uFlags & GIL_NOTFILENAME))
lstrcpyW (psfi->szDisplayName, szLocation);
else
if (uFlags & GIL_NOTFILENAME)
ret = FALSE;
else
{
lstrcpyW (psfi->szDisplayName, szLocation);
psfi->iIcon = iIndex;
}
IExtractIconW_Release(pei);
}
}
}
/* get icon index (or load icon)*/
if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
......
......@@ -140,7 +140,7 @@ static void test_get_file_info(void)
rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
&shfi, sizeof(shfi),
SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
todo_wine ok(rc, "SHGetFileInfoA(c:\\nonexistent) failed\n");
ok(rc, "SHGetFileInfoA(c:\\nonexistent) failed\n");
if (rc)
{
ok(strcpy(shfi.szDisplayName, "dummy") != 0, "SHGetFileInfoA(c:\\nonexistent) displayname is not set\n");
......@@ -157,7 +157,7 @@ static void test_get_file_info(void)
rc=SHGetFileInfoA(notepad, GetFileAttributes(notepad),
&shfi, sizeof(shfi),
SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
todo_wine ok(rc, "SHGetFileInfoA(%s, SHGFI_USEFILEATTRIBUTES) failed\n", notepad);
ok(rc, "SHGetFileInfoA(%s, SHGFI_USEFILEATTRIBUTES) failed\n", notepad);
strcpy(shfi2.szDisplayName, "dummy");
shfi2.iIcon=0xdeadbeef;
rc2=SHGetFileInfoA(notepad, 0,
......@@ -177,7 +177,7 @@ static void test_get_file_info(void)
rc=SHGetFileInfoA("test4.txt", GetFileAttributes("test4.txt"),
&shfi, sizeof(shfi),
SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
todo_wine ok(rc, "SHGetFileInfoA(test4.txt/, SHGFI_USEFILEATTRIBUTES) failed\n");
ok(rc, "SHGetFileInfoA(test4.txt/, SHGFI_USEFILEATTRIBUTES) failed\n");
strcpy(shfi2.szDisplayName, "dummy");
shfi2.iIcon=0xdeadbeef;
rc2=SHGetFileInfoA("test4.txt", 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment