From 0d87e1f9fdfb96648ce03709e9c6bca285ec5c73 Mon Sep 17 00:00:00 2001 From: David Hedberg Date: Sun, 19 Dec 2010 23:15:12 +0100 Subject: [PATCH] shell32: IShellItem::GetAttributes should also work on the desktop shellfolder. --- dlls/shell32/shellitem.c | 5 +++- dlls/shell32/tests/shlfolder.c | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/dlls/shell32/shellitem.c b/dlls/shell32/shellitem.c index d6945038a8..fab754146f 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 c72eed2656..0bf2ec7d90 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) /*