[PATCH 2/3] shell32: IShellItem::GetAttributes should also work on the desktop shellfolder.
David Hedberg
david.hedberg at gmail.com
Sun Dec 19 16:15:12 CST 2010
Emulates the behaviour of vista and above.
---
dlls/shell32/shellitem.c | 5 +++-
dlls/shell32/tests/shlfolder.c | 44 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 1 deletions(-)
diff --git a/dlls/shell32/shellitem.c b/dlls/shell32/shellitem.c
index d694503..fab7541 100644
--- a/dlls/shell32/shellitem.c
+++ b/dlls/shell32/shellitem.c
@@ -259,7 +259,10 @@ static HRESULT WINAPI ShellItem_GetAttributes(IShellItem *iface, SFGAOF sfgaoMas
TRACE("(%p,%x,%p)\n", iface, sfgaoMask, psfgaoAttribs);
- ret = ShellItem_get_parent_shellfolder(This, &parent_folder);
+ if (_ILIsDesktop(This->pidl))
+ ret = SHGetDesktopFolder(&parent_folder);
+ else
+ ret = ShellItem_get_parent_shellfolder(This, &parent_folder);
if (SUCCEEDED(ret))
{
child_pidl = ILFindLastID(This->pidl);
diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c
index c72eed2..0bf2ec7 100644
--- a/dlls/shell32/tests/shlfolder.c
+++ b/dlls/shell32/tests/shlfolder.c
@@ -3670,6 +3670,49 @@ static void test_ShellItemBindToHandler(void)
pILFree(pidl_desktop);
}
+void test_ShellItemGetAttributes(void)
+{
+ IShellItem *psi;
+ LPITEMIDLIST pidl_desktop;
+ SFGAOF sfgao;
+ HRESULT hr;
+
+ if(!pSHCreateShellItem)
+ {
+ skip("SHCreateShellItem missing.\n");
+ return;
+ }
+
+ hr = pSHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl_desktop);
+ ok(hr == S_OK, "Got 0x%08x\n", hr);
+ if(SUCCEEDED(hr))
+ {
+ hr = pSHCreateShellItem(NULL, NULL, pidl_desktop, &psi);
+ ok(hr == S_OK, "Got 0x%08x\n", hr);
+ pILFree(pidl_desktop);
+ }
+ if(FAILED(hr))
+ {
+ skip("Skipping tests.");
+ return;
+ }
+
+ if(0)
+ {
+ /* Crashes on native (Win 7) */
+ hr = IShellItem_GetAttributes(psi, 0, NULL);
+ ok(hr == S_OK, "Got 0x%08x\n", hr);
+ }
+
+ /* Test GetAttributes on the desktop folder. */
+ sfgao = 0xdeadbeef;
+ hr = IShellItem_GetAttributes(psi, SFGAO_FOLDER, &sfgao);
+ ok(hr == S_OK || broken(hr == E_FAIL) /* <Vista */, "Got 0x%08x\n", hr);
+ ok(sfgao == SFGAO_FOLDER || broken(sfgao == 0) /* <Vista */, "Got 0x%08x\n", sfgao);
+
+ IShellItem_Release(psi);
+}
+
static void test_SHParseDisplayName(void)
{
LPITEMIDLIST pidl1, pidl2;
@@ -4432,6 +4475,7 @@ START_TEST(shlfolder)
test_ShellItemCompare();
test_SHChangeNotify();
test_ShellItemBindToHandler();
+ test_ShellItemGetAttributes();
OleUninitialize();
}
--
1.7.3.3
More information about the wine-patches
mailing list