shell32: SHELL32_GetItemAttributes()

Martin Fuchs martin-fuchs at gmx.net
Fri Nov 25 03:59:30 CST 2005


Changelog:
- 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()


Index: shfldr_desktop.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shfldr_desktop.c,v
retrieving revision 1.50
diff -u -p -d -w -b -r1.50 shfldr_desktop.c
--- shfldr_desktop.c	23 Nov 2005 14:25:39 -0000	1.50
+++ shfldr_desktop.c	25 Nov 2005 09:36:34 -0000
@@ -431,6 +431,9 @@ static HRESULT WINAPI ISF_Desktop_fnGetA
     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_fnGetA
             pdump (*apidl);
             if (_ILIsDesktop(*apidl)) { 
                 *rgfInOut &= dwDesktopAttributes;
+            } else if (_ILIsMyComputer(*apidl)) {
+                *rgfInOut &= dwMyComputerAttributes;
             } else {
                 SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut);
             }
Index: shlfolder.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shlfolder.c,v
retrieving revision 1.106
diff -u -p -d -w -b -r1.106 shlfolder.c
--- shlfolder.c	3 Nov 2005 09:56:07 -0000	1.106
+++ shlfolder.c	25 Nov 2005 09:36:35 -0000
@@ -408,14 +408,13 @@ HRESULT SHELL32_GetItemAttributes (IShel
         *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);
 
Index: tests/shlfolder.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/tests/shlfolder.c,v
retrieving revision 1.43
diff -u -p -d -r1.43 shlfolder.c
--- tests/shlfolder.c	9 Nov 2005 10:30:15 -0000	1.43
+++ tests/shlfolder.c	25 Nov 2005 09:57:04 -0000
@@ -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(voi
     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(voi
     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)




More information about the wine-patches mailing list