SHGFI_USEFILEATTRIBUTES support in SHGetFileInfoA

Carlos clozano at andago.com
Sat Oct 26 12:30:55 CDT 2002


Hello,

The function SHGetFileInfoA wasn't supporting the flag
SHGFI_USEFILEATTRIBUTES. 
There is yet a problem when it calls to 
"PrivateExtractIconsA" function, because it doesn't paint
the correct icon. (testing with winrar)

Regards,
Carlos.

-- 
 ___         _          \  |  /  Infraestructuras
| . |._ _  _| | ___  ___  ___    http://www.andago.com
|   || ' |/ . |<_> |/ . |/ . \__ GNU/Linux
|_|_||_|_|\___|<___|\_. |\___/     _ \  __|\ \  /
 Carlos A. Lozano   <___'/ | \ -_) __/\__ \ >  <  -_)
 [ carlos.lozano at andago.com ]\___|_|  ____/ _/\_\___|
 [ calb at epsxe.com           ]  http://www.epsxe.com
-------------- next part --------------
Index: dlls/shell32/shell32_main.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell32_main.c,v
retrieving revision 1.102
diff -u -r1.102 shell32_main.c
--- dlls/shell32/shell32_main.c	23 Oct 2002 20:20:59 -0000	1.102
+++ dlls/shell32/shell32_main.c	26 Oct 2002 17:35:15 -0000
@@ -297,14 +297,17 @@
 	    hr = SHILCreateFromPathA(path, &pidl, &dwAttributes);
 	}
 
-	/* get the parent shellfolder */
-	if (pidl) {
-	    hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
-	    ILFree(pidl);
-	} else {
-	    ERR("pidl is null!\n");
-	    return FALSE;
-	}
+        if ((flags & SHGFI_PIDL) || !(flags & SHGFI_USEFILEATTRIBUTES))
+        {
+	   /* get the parent shellfolder */
+	   if (pidl) {
+	      hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
+	      ILFree(pidl);
+	   } else {
+	      ERR("pidl is null!\n");
+	      return FALSE;
+	   }
+        }
 
 	/* get the attributes of the child */
 	if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
@@ -338,13 +341,18 @@
                 _ILGetFileType(pidlLast, psfi->szTypeName, 80);
             else
             {
-                char sTemp[64];
-                strcpy(sTemp,PathFindExtensionA(path));
-                if (!( HCR_MapTypeToValue(sTemp, sTemp, 64, TRUE)
-                       && HCR_MapTypeToValue(sTemp, psfi->szTypeName, 80, FALSE )))
+                if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+                   strcat (psfi->szTypeName, "File");
+                else 
                 {
-                    lstrcpynA (psfi->szTypeName, sTemp, 80 - 6);
-                    strcat (psfi->szTypeName, "-file");
+                   char sTemp[64];
+                   strcpy(sTemp,PathFindExtensionA(path));
+                   if (!( HCR_MapTypeToValue(sTemp, sTemp, 64, TRUE)
+                        && HCR_MapTypeToValue(sTemp, psfi->szTypeName, 80, FALSE )))
+                   {
+                       lstrcpynA (psfi->szTypeName, sTemp, 64);
+                       strcat (psfi->szTypeName, "-file");
+                   }
                 }
             }
         }
@@ -390,28 +398,26 @@
 	    DWORD dwNr=0;
 
 	    lstrcpynA(sTemp, path, MAX_PATH);
-	    szExt = (LPSTR) PathFindExtensionA(sTemp);
-	    if( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE)
-              && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
-            {
-              if (!strcmp("%1",sTemp))            /* icon is in the file */
-              {
-                strcpy(sTemp, path);
-              }
-              IconNotYetLoaded=FALSE;
-              psfi->iIcon = 0;
-              if (SHGFI_LARGEICON)
-                PrivateExtractIconsA(sTemp,dwNr,GetSystemMetrics(SM_CXICON),
-                                     GetSystemMetrics(SM_CYICON),
-                                     &psfi->hIcon,0,1,0);
-              else
-                PrivateExtractIconsA(sTemp,dwNr,GetSystemMetrics(SM_CXSMICON),
-                                     GetSystemMetrics(SM_CYSMICON),
-                                     &psfi->hIcon,0,1,0);
-            }
-            else                                  /* default icon */
+
+            if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+               psfi->iIcon = 2;
+            else
             {
-              psfi->iIcon = 0;
+               psfi->iIcon = 0;
+               szExt = (LPSTR) PathFindExtensionA(sTemp);
+               if ( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE)
+                   && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
+               {
+                  if (!strcmp("%1",sTemp))            /* icon is in the file */
+                     strcpy(sTemp, path);
+              
+                  IconNotYetLoaded=FALSE;
+                  /* FIXME: is it working correctly? */
+                  PrivateExtractIconsA(sTemp,dwNr,(flags&SHGFI_LARGEICON) ? 
+                    GetSystemMetrics(SM_CXICON) : GetSystemMetrics(SM_CXSMICON),
+                    (flags&SHGFI_LARGEICON) ? GetSystemMetrics(SM_CYICON) :
+                    GetSystemMetrics(SM_CYSMICON), &psfi->hIcon,0,1,0);
+               }
             }
 	  }
 	  else


More information about the wine-patches mailing list