From 0b17529332b0ef5ee57873afd4ded6f359e76781 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Mon, 28 Nov 2005 10:38:06 +0100 Subject: [PATCH] Correctly call HCR_GetFolderAttributes() in SHELL32_GetItemAttributes(). Directly return the correct "My Computer" attributes in ISF_Desktop_fnGetAttributesOf(). Remove "todo_wine" from the "My Computer" attributes test case. Add test case for retrieving the file system path from the CSIDL_PROGRAM_FILES PIDL using SHGetPathFromIDListW(). --- dlls/shell32/shfldr_desktop.c | 5 +++++ dlls/shell32/shlfolder.c | 9 ++++----- dlls/shell32/tests/shlfolder.c | 20 ++++++++++++++++++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/dlls/shell32/shfldr_desktop.c b/dlls/shell32/shfldr_desktop.c index 2cb56320610..09d62701736 100644 --- a/dlls/shell32/shfldr_desktop.c +++ b/dlls/shell32/shfldr_desktop.c @@ -431,6 +431,9 @@ static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf (IShellFolder2 * iface, static const DWORD dwDesktopAttributes = SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR | SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER; + static const DWORD dwMyComputerAttributes = + SFGAO_CANRENAME | SFGAO_CANDELETE | SFGAO_HASPROPSHEET | + SFGAO_DROPTARGET | SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_HASSUBFOLDER; TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08lx))\n", This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0); @@ -450,6 +453,8 @@ static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf (IShellFolder2 * iface, pdump (*apidl); if (_ILIsDesktop(*apidl)) { *rgfInOut &= dwDesktopAttributes; + } else if (_ILIsMyComputer(*apidl)) { + *rgfInOut &= dwMyComputerAttributes; } else { SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut); } diff --git a/dlls/shell32/shlfolder.c b/dlls/shell32/shlfolder.c index 55397ebd9b1..d033b2a298a 100644 --- a/dlls/shell32/shlfolder.c +++ b/dlls/shell32/shlfolder.c @@ -408,14 +408,13 @@ HRESULT SHELL32_GetItemAttributes (IShellFolder * psf, LPCITEMIDLIST pidl, LPDWO *pdwAttributes &= dwSupportedAttr; } + dwAttributes = *pdwAttributes; + if (_ILIsDrive (pidl)) { *pdwAttributes &= SFGAO_HASSUBFOLDER|SFGAO_FILESYSTEM|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR| SFGAO_DROPTARGET|SFGAO_HASPROPSHEET|SFGAO_CANLINK; - } else if (_ILGetGUIDPointer (pidl)) { - if (!HCR_GetFolderAttributes (pidl, pdwAttributes)) { - *pdwAttributes &= SFGAO_HASSUBFOLDER|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR| - SFGAO_DROPTARGET|SFGAO_HASPROPSHEET|SFGAO_CANRENAME|SFGAO_CANLINK; - } + } else if (_ILGetGUIDPointer (pidl) && HCR_GetFolderAttributes(pidl, &dwAttributes)) { + *pdwAttributes = dwAttributes; } else if (_ILGetDataPointer (pidl)) { dwAttributes = _ILGetFileAttributes (pidl, NULL, 0); diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c index 5d33601bb14..db6a7a97534 100644 --- a/dlls/shell32/tests/shlfolder.c +++ b/dlls/shell32/tests/shlfolder.c @@ -602,8 +602,8 @@ static void test_GetAttributesOf(void) dwFlags = 0xffffffff; hr = IShellFolder_GetAttributesOf(psfDesktop, 1, (LPCITEMIDLIST*)&pidlMyComputer, &dwFlags); ok (SUCCEEDED(hr), "Desktop->GetAttributesOf(MyComputer) failed! hr = %08lx\n", hr); - todo_wine { ok ((dwFlags & ~(DWORD)SFGAO_CANLINK) == dwMyComputerFlags, - "Wrong MyComputer attributes: %08lx, expected: %08lx\n", dwFlags, dwMyComputerFlags); } + ok ((dwFlags & ~(DWORD)SFGAO_CANLINK) == dwMyComputerFlags, + "Wrong MyComputer attributes: %08lx, expected: %08lx\n", dwFlags, dwMyComputerFlags); hr = IShellFolder_BindToObject(psfDesktop, pidlMyComputer, NULL, &IID_IShellFolder, (LPVOID*)&psfMyComputer); ok (SUCCEEDED(hr), "Desktop failed to bind to MyComputer object! hr = %08lx\n", hr); @@ -641,6 +641,9 @@ static void test_SHGetPathFromIDList(void) STRRET strret; static WCHAR wszTestFile[] = { 'w','i','n','e','t','e','s','t','.','f','o','o',0 }; + HRESULT (WINAPI *pSHGetSpecialFolderLocation)(HWND, int, LPITEMIDLIST *); + HMODULE hShell32; + LPITEMIDLIST pidlPrograms; if(!pSHGetSpecialFolderPathW) return; @@ -725,6 +728,19 @@ static void test_SHGetPathFromIDList(void) IMalloc_Free(ppM, pidlTestFile); if (!result) return; ok(0 == lstrcmpW(wszFileName, wszPath), "SHGetPathFromIDListW returned incorrect path for file placed on desktop\n"); + + + /* Test if we can get the path from the start menu "program files" PIDL. */ + hShell32 = GetModuleHandleA("shell32"); + pSHGetSpecialFolderLocation = (HRESULT(WINAPI*)(HWND,int,LPITEMIDLIST*))GetProcAddress(hShell32, "SHGetSpecialFolderLocation"); + + hr = pSHGetSpecialFolderLocation(NULL, CSIDL_PROGRAM_FILES, &pidlPrograms); + ok(SUCCEEDED(hr), "SHGetFolderLocation failed: 0x%08lx\n", hr); + + SetLastError(0xdeadbeef); + result = SHGetPathFromIDListW(pidlPrograms, wszPath); + IMalloc_Free(ppM, pidlPrograms); + ok(result, "SHGetPathFromIDList failed\n"); } static void test_EnumObjects_and_CompareIDs(void)