shell32: Add proper support for SHGetFileInfo(SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES).
This commit is contained in:
parent
5c5933f699
commit
aa3165fca6
|
@ -356,14 +356,6 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
|
||||||
(flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
|
(flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
|
||||||
return FALSE;
|
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 */
|
/* windows initializes these values regardless of the flags */
|
||||||
if (psfi != NULL)
|
if (psfi != NULL)
|
||||||
{
|
{
|
||||||
|
@ -519,21 +511,56 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
|
||||||
{
|
{
|
||||||
UINT uDummy,uFlags;
|
UINT uDummy,uFlags;
|
||||||
|
|
||||||
hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1,
|
if (flags & SHGFI_USEFILEATTRIBUTES)
|
||||||
(LPCITEMIDLIST*)&pidlLast, &IID_IExtractIconW,
|
|
||||||
&uDummy, (LPVOID*)&pei);
|
|
||||||
if (SUCCEEDED(hr))
|
|
||||||
{
|
{
|
||||||
hr = IExtractIconW_GetIconLocation(pei, uGilFlags,
|
if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
szLocation, MAX_PATH, &iIndex, &uFlags);
|
{
|
||||||
psfi->iIcon = iIndex;
|
lstrcpyW(psfi->szDisplayName, swShell32Name);
|
||||||
|
psfi->iIcon = -IDI_SHELL_FOLDER;
|
||||||
if (!(uFlags & GIL_NOTFILENAME))
|
}
|
||||||
lstrcpyW (psfi->szDisplayName, szLocation);
|
|
||||||
else
|
else
|
||||||
ret = FALSE;
|
{
|
||||||
|
WCHAR* szExt;
|
||||||
|
static const WCHAR p1W[] = {'%','1',0};
|
||||||
|
WCHAR sTemp [MAX_PATH];
|
||||||
|
|
||||||
IExtractIconW_Release(pei);
|
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);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
hr = IExtractIconW_GetIconLocation(pei, uGilFlags,
|
||||||
|
szLocation, MAX_PATH, &iIndex, &uFlags);
|
||||||
|
|
||||||
|
if (uFlags & GIL_NOTFILENAME)
|
||||||
|
ret = FALSE;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lstrcpyW (psfi->szDisplayName, szLocation);
|
||||||
|
psfi->iIcon = iIndex;
|
||||||
|
}
|
||||||
|
IExtractIconW_Release(pei);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ static void test_get_file_info(void)
|
||||||
rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
|
rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
|
||||||
&shfi, sizeof(shfi),
|
&shfi, sizeof(shfi),
|
||||||
SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
|
SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
|
||||||
todo_wine ok(rc, "SHGetFileInfoA(c:\\nonexistent) failed\n");
|
ok(rc, "SHGetFileInfoA(c:\\nonexistent) failed\n");
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
ok(strcpy(shfi.szDisplayName, "dummy") != 0, "SHGetFileInfoA(c:\\nonexistent) displayname is not set\n");
|
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),
|
rc=SHGetFileInfoA(notepad, GetFileAttributes(notepad),
|
||||||
&shfi, sizeof(shfi),
|
&shfi, sizeof(shfi),
|
||||||
SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
|
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");
|
strcpy(shfi2.szDisplayName, "dummy");
|
||||||
shfi2.iIcon=0xdeadbeef;
|
shfi2.iIcon=0xdeadbeef;
|
||||||
rc2=SHGetFileInfoA(notepad, 0,
|
rc2=SHGetFileInfoA(notepad, 0,
|
||||||
|
@ -177,7 +177,7 @@ static void test_get_file_info(void)
|
||||||
rc=SHGetFileInfoA("test4.txt", GetFileAttributes("test4.txt"),
|
rc=SHGetFileInfoA("test4.txt", GetFileAttributes("test4.txt"),
|
||||||
&shfi, sizeof(shfi),
|
&shfi, sizeof(shfi),
|
||||||
SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
|
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");
|
strcpy(shfi2.szDisplayName, "dummy");
|
||||||
shfi2.iIcon=0xdeadbeef;
|
shfi2.iIcon=0xdeadbeef;
|
||||||
rc2=SHGetFileInfoA("test4.txt", 0,
|
rc2=SHGetFileInfoA("test4.txt", 0,
|
||||||
|
|
Loading…
Reference in New Issue