Change SHGetFileInfo to avoid W -> A call
Rolf Kalbermatter
rolf.kalbermatter at citeng.com
Thu Dec 12 13:55:06 CST 2002
Changelog
* dlls/shell32/shell32_main.c
Change SHGetFileInfo to avoid W -> A call
* dlls/shell32/shell32_main.h
Change SIC_GetIconIndex path parameter to Unicode
* dlls/shell32/iconcache.c
Change SIC_ functions to use Unicode path
Rolf Kalbermatter
Index: dlls/shell32/shell32_main.h
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell32_main.h,v
retrieving revision 1.59
diff -u -r1.59 shell32_main.h
--- dlls/shell32/shell32_main.h 6 Dec 2002 23:20:52 -0000 1.59
+++ dlls/shell32/shell32_main.h 12 Dec 2002 19:48:03 -0000
@@ -41,6 +41,7 @@
extern HIMAGELIST ShellSmallIconList;
extern HIMAGELIST ShellBigIconList;
extern HDPA sic_hdpa;
+extern WCHAR swShell32Name[];
/*******************************************
* pointer to functions dynamically loaded
@@ -53,8 +54,8 @@
#define INVALID_INDEX -1
BOOL SIC_Initialize(void);
void SIC_Destroy(void);
-BOOL PidlToSicIndex (IShellFolder * sh, LPITEMIDLIST pidl, BOOL bBigIcon, UINT uFlags, UINT * pIndex);
-INT SIC_GetIconIndex (LPCSTR sSourceFile, INT dwSourceIndex );
+BOOL PidlToSicIndex(IShellFolder * sh, LPITEMIDLIST pidl, BOOL bBigIcon, UINT uFlags, UINT * pIndex);
+INT SIC_GetIconIndex(LPCWSTR sSourceFile, INT dwSourceIndex);
/* Classes Root */
BOOL HCR_MapTypeToValue ( LPCSTR szExtension, LPSTR szFileType, DWORD len, BOOL bPrependDot);
Index: dlls/shell32/shell32_main.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell32_main.c,v
retrieving revision 1.109
diff -u -r1.109 shell32_main.c
--- dlls/shell32/shell32_main.c 12 Dec 2002 02:17:13 -0000 1.109
+++ dlls/shell32/shell32_main.c 12 Dec 2002 19:48:55 -0000
@@ -46,6 +46,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(shell);
+WCHAR swShell32Name[] = {'s','h','e','l','l','3','2','.','d','l','l',0};
+
#define MORE_DEBUG 1
/*************************************************************************
* CommandLineToArgvW [SHELL32.@]
@@ -201,30 +203,30 @@
}
/*************************************************************************
- * SHGetFileInfoA [SHELL32.@]
+ * SHGetFileInfoW [SHELL32.@]
*
*/
+static WCHAR swFolder[] = {'F','o','l','d','e','r',0};
-DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
- SHFILEINFOA *psfi, UINT sizeofpsfi,
- UINT flags )
+DWORD WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes,
+ SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags )
{
- char szLocation[MAX_PATH];
- int iIndex;
+ WCHAR szLocation[MAX_PATH];
DWORD ret = TRUE, dwAttributes = 0;
IShellFolder * psfParent = NULL;
- IExtractIconA * pei = NULL;
+ IExtractIconW *peiw = NULL;
+ IExtractIconA *peia = NULL;
LPITEMIDLIST pidlLast = NULL, pidl = NULL;
HRESULT hr = S_OK;
- BOOL IconNotYetLoaded=TRUE;
+ BOOL IconNotYetLoaded = TRUE;
TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
- (flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags);
+ (flags & SHGFI_PIDL)? "pidl" : debugstr_w(path), dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags);
- if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
+ if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES | SHGFI_EXETYPE | SHGFI_PIDL)))
return FALSE;
- /* windows initializes this values regardless of the flags */
+ /* windows initializes these values regardless of the flags */
psfi->szDisplayName[0] = '\0';
psfi->szTypeName[0] = '\0';
psfi->iIcon = 0;
@@ -240,14 +242,15 @@
if (flags != SHGFI_EXETYPE) return 0;
- status = GetBinaryTypeA (path, &BinaryType);
+ status = GetBinaryTypeW (path, &BinaryType);
if (!status) return 0;
- if ((BinaryType == SCS_DOS_BINARY)
- || (BinaryType == SCS_PIF_BINARY)) return 0x4d5a;
+ if ((BinaryType == SCS_DOS_BINARY) || (BinaryType == SCS_PIF_BINARY))
+ return 0x4d5a;
- hfile = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ,
- NULL, OPEN_EXISTING, 0, 0 );
- if ( hfile == INVALID_HANDLE_VALUE ) return 0;
+ hfile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, 0, 0);
+ if (hfile == INVALID_HANDLE_VALUE)
+ return 0;
/* The next section is adapted from MODULE_GetBinaryType, as we need
* to examine the image header to get OS and version information. We
@@ -259,55 +262,62 @@
SetFilePointer( hfile, 0, NULL, SEEK_SET );
ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL );
- SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
- ReadFile( hfile, magic, sizeof(magic), &len, NULL );
- if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE )
- {
- SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
- ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
- CloseHandle( hfile );
- if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) {
- return IMAGE_NT_SIGNATURE
- | (nt.OptionalHeader.MajorSubsystemVersion << 24)
- | (nt.OptionalHeader.MinorSubsystemVersion << 16);
- }
- return IMAGE_NT_SIGNATURE;
+ SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
+ ReadFile( hfile, magic, sizeof(magic), &len, NULL );
+ if (*(DWORD*)magic == IMAGE_NT_SIGNATURE)
+ {
+ SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
+ ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
+ CloseHandle( hfile );
+ if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI)
+ {
+ return IMAGE_NT_SIGNATURE
+ | (nt.OptionalHeader.MajorSubsystemVersion << 24)
+ | (nt.OptionalHeader.MinorSubsystemVersion << 16);
+ }
+ return IMAGE_NT_SIGNATURE;
}
- else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE )
- {
- IMAGE_OS2_HEADER ne;
- SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
- ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
- CloseHandle( hfile );
- if (ne.ne_exetyp == 2) return IMAGE_OS2_SIGNATURE
- | (ne.ne_expver << 16);
- return 0;
+ else if (*(WORD*)magic == IMAGE_OS2_SIGNATURE)
+ {
+ IMAGE_OS2_HEADER ne;
+ SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
+ ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
+ CloseHandle( hfile );
+ if (ne.ne_exetyp == 2)
+ return IMAGE_OS2_SIGNATURE | (ne.ne_expver << 16);
+ return 0;
}
CloseHandle( hfile );
return 0;
- }
+ }
- /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
+ /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES is not specified
the pidl functions fail on not existing file names */
- if (flags & SHGFI_PIDL) {
- pidl = ILClone((LPCITEMIDLIST)path);
- } else if (!(flags & SHGFI_USEFILEATTRIBUTES)) {
- hr = SHILCreateFromPathA(path, &pidl, &dwAttributes);
+ if (flags & SHGFI_PIDL)
+ {
+ pidl = ILClone((LPCITEMIDLIST)path);
+ }
+ else if (!(flags & SHGFI_USEFILEATTRIBUTES))
+ {
+ hr = SHILCreateFromPathW(path, &pidl, &dwAttributes);
}
- 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;
- }
- }
+ 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))
@@ -324,38 +334,41 @@
{
if (flags & SHGFI_USEFILEATTRIBUTES)
{
- strcpy (psfi->szDisplayName, PathFindFileNameA(path));
+ lstrcpynW(psfi->szDisplayName, PathFindFileNameW(path), MAX_PATH);
}
else
{
STRRET str;
hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str);
- StrRetToStrNA (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
+ StrRetToStrNW(psfi->szDisplayName, MAX_PATH, &str, pidlLast);
}
}
/* get the type name */
if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
- {
- if (!(flags & SHGFI_USEFILEATTRIBUTES))
- _ILGetFileType(pidlLast, psfi->szTypeName, 80);
- else
- {
- if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- strcat (psfi->szTypeName, "File");
- else
- {
- 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");
- }
- }
- }
- }
+ {
+ char sTemp[80];
+ if (!(flags & SHGFI_USEFILEATTRIBUTES))
+ {
+ _ILGetFileType(pidlLast, sTemp, 80);
+ MultiByteToWideChar(CP_ACP, 0, sTemp, -1, psfi->szTypeName, 80);
+ }
+ else
+ {
+ if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ lstrcpynW(psfi->szTypeName, swFolder, 80);
+ else
+ {
+ WideCharToMultiByte(CP_ACP, 0, PathFindExtensionW(path), -1, sTemp, 80, 0, NULL);
+ if (!(HCR_MapTypeToValue(sTemp, sTemp, 80, TRUE)
+ && HCR_MapTypeToValue(sTemp, sTemp, 80, FALSE)))
+ {
+ lstrcatA(sTemp, "-file");
+ }
+ MultiByteToWideChar(CP_ACP, 0, sTemp, -1, psfi->szTypeName, 80);
+ }
+ }
+ }
/* ### icons ###*/
if (flags & SHGFI_LINKOVERLAY)
@@ -371,62 +384,74 @@
if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
{
UINT uDummy,uFlags;
- hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
-
+ hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconW, &uDummy, (LPVOID*)&peiw);
if (SUCCEEDED(hr))
{
- hr = IExtractIconA_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLocation, MAX_PATH, &iIndex, &uFlags);
- /* FIXME what to do with the index? */
-
- if(uFlags != GIL_NOTFILENAME)
- strcpy (psfi->szDisplayName, szLocation);
+ hr = IExtractIconW_GetIconLocation(peiw, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, szLocation, MAX_PATH, &psfi->iIcon, &uFlags);
+ if (SUCCEEDED(hr) && !(uFlags & GIL_NOTFILENAME))
+ strncpyW(psfi->szDisplayName, szLocation, MAX_PATH);
else
ret = FALSE;
-
- IExtractIconA_Release(pei);
+ IExtractIconW_Release(peiw);
+ }
+ else
+ {
+ /* No Unicode Icon extractor, try ANSI */
+ char szLocation[MAX_PATH];
+
+ hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&peia);
+ if (SUCCEEDED(hr))
+ {
+ hr = IExtractIconA_GetIconLocation(peia, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, szLocation, MAX_PATH, &psfi->iIcon, &uFlags);
+ if (SUCCEEDED(hr) && !(uFlags & GIL_NOTFILENAME))
+ MultiByteToWideChar(CP_ACP, 0, szLocation, -1, psfi->szDisplayName, MAX_PATH);
+ else
+ ret = FALSE;
+ IExtractIconA_Release(peia);
+ }
}
}
/* get icon index (or load icon)*/
if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
{
-
if (flags & SHGFI_USEFILEATTRIBUTES)
{
char sTemp [MAX_PATH];
- char * szExt;
- DWORD dwNr=0;
+ DWORD dwNr = 0;
- lstrcpynA(sTemp, path, MAX_PATH);
+ if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ psfi->iIcon = 2;
+ else
+ {
+ psfi->iIcon = 0;
+ WideCharToMultiByte(CP_ACP, 0, PathFindExtensionW(path), -1, sTemp, MAX_PATH, 0, NULL);
- if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- psfi->iIcon = 2;
- else
- {
- 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);
-
- if (flags & SHGFI_SYSICONINDEX)
- {
- psfi->iIcon = SIC_GetIconIndex(sTemp,dwNr);
- if (psfi->iIcon == -1) psfi->iIcon = 0;
- }
- else
- {
- IconNotYetLoaded=FALSE;
- 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);
- psfi->iIcon = dwNr;
- }
- }
- }
+ if (HCR_MapTypeToValue(sTemp, sTemp, MAX_PATH, TRUE)
+ && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
+ {
+ if (!lstrcmpA("%1", sTemp)) /* icon is in the file */
+ lstrcpynW(szLocation, path, MAX_PATH);
+ else
+ MultiByteToWideChar(CP_ACP, 0, sTemp, -1, szLocation, MAX_PATH);
+
+ if (flags & SHGFI_SYSICONINDEX)
+ {
+ psfi->iIcon = SIC_GetIconIndex(szLocation, dwNr);
+ if (psfi->iIcon == -1)
+ psfi->iIcon = 0;
+ }
+ else
+ {
+ IconNotYetLoaded = FALSE;
+ PrivateExtractIconsW(szLocation, dwNr, (flags & SHGFI_LARGEICON) ?
+ GetSystemMetrics(SM_CXICON) : GetSystemMetrics(SM_CXSMICON),
+ (flags&SHGFI_LARGEICON) ? GetSystemMetrics(SM_CYICON) :
+ GetSystemMetrics(SM_CYSMICON), &psfi->hIcon, 0, 1, 0);
+ psfi->iIcon = dwNr;
+ }
+ }
+ }
}
else
{
@@ -464,39 +489,45 @@
}
/*************************************************************************
- * SHGetFileInfoW [SHELL32.@]
+ * SHGetFileInfoA [SHELL32.@]
*/
-DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
- SHFILEINFOW *psfi, UINT sizeofpsfi,
- UINT flags )
+DWORD WINAPI SHGetFileInfoA(LPCSTR path, DWORD dwFileAttributes,
+ SHFILEINFOA *psfi, UINT sizeofpsfi, UINT flags)
{
INT len;
- LPSTR temppath;
+ LPWSTR temppath = NULL;
DWORD ret;
- SHFILEINFOA temppsfi;
+ SHFILEINFOW temppsfi;
+
+ if (!(flags & SHGFI_PIDL))
+ {
+ len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
+ temppath = HeapAlloc(GetProcessHeap(), 0, len);
+ MultiByteToWideChar(CP_ACP, 0, path, -1, temppath, len);
+ }
+ if (flags & SHGFI_ATTR_SPECIFIED)
+ temppsfi.dwAttributes = psfi->dwAttributes;
+
+ ret = SHGetFileInfoW(temppath, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
+
+ if (flags & SHGFI_ICON)
+ psfi->hIcon = temppsfi.hIcon;
+
+ if(flags & (SHGFI_SYSICONINDEX | SHGFI_ICON | SHGFI_ICONLOCATION))
+ psfi->iIcon = temppsfi.iIcon;
+
+ if(flags & SHGFI_ATTRIBUTES)
+ psfi->dwAttributes = temppsfi.dwAttributes;
+
+ if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION))
+ WideCharToMultiByte(CP_ACP, 0, temppsfi.szDisplayName, -1, psfi->szDisplayName, MAX_PATH, 0, NULL);
- len = WideCharToMultiByte(CP_ACP, 0, path, -1, NULL, 0, NULL, NULL);
- temppath = HeapAlloc(GetProcessHeap(), 0, len);
- WideCharToMultiByte(CP_ACP, 0, path, -1, temppath, len, NULL, NULL);
-
- if(flags & SHGFI_ATTR_SPECIFIED)
- temppsfi.dwAttributes=psfi->dwAttributes;
-
- ret = SHGetFileInfoA(temppath, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
-
- if(flags & SHGFI_ICON)
- psfi->hIcon=temppsfi.hIcon;
- if(flags & (SHGFI_SYSICONINDEX|SHGFI_ICON|SHGFI_ICONLOCATION))
- psfi->iIcon=temppsfi.iIcon;
- if(flags & SHGFI_ATTRIBUTES)
- psfi->dwAttributes=temppsfi.dwAttributes;
- if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION))
- MultiByteToWideChar(CP_ACP, 0, temppsfi.szDisplayName, -1, psfi->szDisplayName, sizeof(psfi->szDisplayName));
- if(flags & SHGFI_TYPENAME)
- MultiByteToWideChar(CP_ACP, 0, temppsfi.szTypeName, -1, psfi->szTypeName, sizeof(psfi->szTypeName));
+ if(flags & SHGFI_TYPENAME)
+ WideCharToMultiByte(CP_ACP, 0, temppsfi.szTypeName, -1, psfi->szTypeName, 80, 0, NULL);
- HeapFree(GetProcessHeap(), 0, temppath);
+ if (temppath)
+ HeapFree(GetProcessHeap(), 0, temppath);
return ret;
}
Index: dlls/shell32/iconcache.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/iconcache.c,v
retrieving revision 1.65
diff -u -r1.65 iconcache.c
--- dlls/shell32/iconcache.c 10 Dec 2002 19:10:11 -0000 1.65
+++ dlls/shell32/iconcache.c 12 Dec 2002 19:51:23 -0000
@@ -50,7 +50,7 @@
typedef struct
{
- LPSTR sSourceFile; /* file (not path!) containing the icon */
+ LPWSTR sSourceFile; /* file (not path!) containing the icon */
DWORD dwSourceIndex; /* index within the file, if it is a resoure ID it will be negated */
DWORD dwListIndex; /* index within the iconlist */
DWORD dwFlags; /* GIL_* flags */
@@ -66,13 +66,13 @@
* NOTES
* Callback for DPA_Search
*/
-static INT CALLBACK SIC_CompareEntries( LPVOID p1, LPVOID p2, LPARAM lparam)
+static INT CALLBACK SIC_CompareEntries(LPVOID p1, LPVOID p2, LPARAM lparam)
{ TRACE("%p %p %8lx\n", p1, p2, lparam);
if (((LPSIC_ENTRY)p1)->dwSourceIndex != ((LPSIC_ENTRY)p2)->dwSourceIndex) /* first the faster one*/
return 1;
- if (strcasecmp(((LPSIC_ENTRY)p1)->sSourceFile,((LPSIC_ENTRY)p2)->sSourceFile))
+ if (lstrcmpiW(((LPSIC_ENTRY)p1)->sSourceFile,((LPSIC_ENTRY)p2)->sSourceFile))
return 1;
return 0;
@@ -83,17 +83,17 @@
* NOTES
* appends a icon pair to the end of the cache
*/
-static INT SIC_IconAppend (LPCSTR sSourceFile, INT dwSourceIndex, HICON hSmallIcon, HICON hBigIcon)
+static INT SIC_IconAppend(LPCWSTR sSourceFile, INT dwSourceIndex, HICON hSmallIcon, HICON hBigIcon)
{ LPSIC_ENTRY lpsice;
INT ret, index, index1;
- char *path;
- TRACE("%s %i %p %p\n", sSourceFile, dwSourceIndex, hSmallIcon ,hBigIcon);
+ WCHAR *path;
+ TRACE("%s %i %p %p\n", debugstr_w(sSourceFile), dwSourceIndex, hSmallIcon ,hBigIcon);
lpsice = (LPSIC_ENTRY) SHAlloc (sizeof (SIC_ENTRY));
- path = PathFindFileNameA(sSourceFile);
- lpsice->sSourceFile = HeapAlloc( GetProcessHeap(), 0, strlen(path)+1 );
- strcpy( lpsice->sSourceFile, path );
+ path = PathFindFileNameW(sSourceFile);
+ lpsice->sSourceFile = HeapAlloc(GetProcessHeap(), 0, lstrlenW(path) + 1);
+ lstrcpyW(lpsice->sSourceFile, path);
lpsice->dwSourceIndex = dwSourceIndex;
@@ -127,19 +127,20 @@
* NOTES
* gets small/big icon by number from a file
*/
-static INT SIC_LoadIcon (LPCSTR sSourceFile, INT dwSourceIndex)
+static INT SIC_LoadIcon(LPCWSTR sSourceFile, INT dwSourceIndex)
{ HICON hiconLarge=0;
HICON hiconSmall=0;
+ UINT csm = GetSystemMetrics(SM_CXSMICON), clg = GetSystemMetrics(SM_CXICON);
- PrivateExtractIconsA( sSourceFile, dwSourceIndex, 32, 32, &hiconLarge, 0, 1, 0 );
- PrivateExtractIconsA( sSourceFile, dwSourceIndex, 16, 16, &hiconSmall, 0, 1, 0 );
+ PrivateExtractIconsW(sSourceFile, dwSourceIndex, clg, clg, &hiconLarge, NULL, 1, LR_DEFAULTCOLOR);
+ PrivateExtractIconsW(sSourceFile, dwSourceIndex, csm, csm, &hiconSmall, NULL, 1, LR_DEFAULTCOLOR);
- if ( !hiconLarge || !hiconSmall)
+ if (!hiconLarge || !hiconSmall)
{
- WARN("failure loading icon %i from %s (%p %p)\n", dwSourceIndex, sSourceFile, hiconLarge, hiconSmall);
+ WARN("failure loading icon %i from %s (%p %p)\n", dwSourceIndex, debugstr_w(sSourceFile), hiconLarge, hiconSmall);
return -1;
}
- return SIC_IconAppend (sSourceFile, dwSourceIndex, hiconSmall, hiconLarge);
+ return SIC_IconAppend(sSourceFile, dwSourceIndex, hiconSmall, hiconLarge);
}
/*****************************************************************************
* SIC_GetIconIndex [internal]
@@ -152,13 +153,13 @@
* look in the cache for a proper icon. if not available the icon is taken
* from the file and cached
*/
-INT SIC_GetIconIndex (LPCSTR sSourceFile, INT dwSourceIndex )
+INT SIC_GetIconIndex(LPCWSTR sSourceFile, INT dwSourceIndex )
{ SIC_ENTRY sice;
INT ret, index = INVALID_INDEX;
- TRACE("%s %i\n", sSourceFile, dwSourceIndex);
+ TRACE("%s %i\n", debugstr_w(sSourceFile), dwSourceIndex);
- sice.sSourceFile = PathFindFileNameA(sSourceFile);
+ sice.sSourceFile = PathFindFileNameW(sSourceFile);
sice.dwSourceIndex = dwSourceIndex;
EnterCriticalSection(&SHELL32_SicCS);
@@ -188,10 +189,10 @@
* NOTES
* retrieves the specified icon from the iconcache. if not found tries to load the icon
*/
-static HICON WINE_UNUSED SIC_GetIcon (LPCSTR sSourceFile, INT dwSourceIndex, BOOL bSmallIcon )
+static HICON WINE_UNUSED SIC_GetIcon(LPCWSTR sSourceFile, INT dwSourceIndex, BOOL bSmallIcon)
{ INT index;
- TRACE("%s %i\n", sSourceFile, dwSourceIndex);
+ TRACE("%s %i\n", debugstr_w(sSourceFile), dwSourceIndex);
index = SIC_GetIconIndex(sSourceFile, dwSourceIndex);
@@ -216,6 +217,7 @@
{
HICON hSm, hLg;
UINT index;
+ UINT csm = GetSystemMetrics(SM_CXSMICON), clg = GetSystemMetrics(SM_CXICON);
TRACE("\n");
@@ -229,26 +231,26 @@
return(FALSE);
}
- ShellSmallIconList = ImageList_Create(16,16,ILC_COLORDDB | ILC_MASK,0,0x20);
- ShellBigIconList = ImageList_Create(32,32,ILC_COLORDDB | ILC_MASK,0,0x20);
+ ShellSmallIconList = ImageList_Create(csm, csm, ILC_COLORDDB | ILC_MASK, 0, 0x20);
+ ShellBigIconList = ImageList_Create(clg, clg, ILC_COLORDDB | ILC_MASK, 0, 0x20);
ImageList_SetBkColor(ShellSmallIconList, GetSysColor(COLOR_WINDOW));
ImageList_SetBkColor(ShellBigIconList, GetSysColor(COLOR_WINDOW));
for (index=1; index<39; index++)
{
- hSm = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(index), IMAGE_ICON, 16, 16,LR_SHARED);
- hLg = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(index), IMAGE_ICON, 32, 32,LR_SHARED);
+ hSm = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(index), IMAGE_ICON, csm, csm, LR_SHARED);
+ hLg = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(index), IMAGE_ICON, clg, clg, LR_SHARED);
if(!hSm)
{
- hSm = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(0), IMAGE_ICON, 16, 16,LR_SHARED);
- hLg = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(0), IMAGE_ICON, 32, 32,LR_SHARED);
+ hSm = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(0), IMAGE_ICON, csm, csm, LR_SHARED);
+ hLg = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(0), IMAGE_ICON, clg, clg, LR_SHARED);
}
- SIC_IconAppend ("shell32.dll", index, hSm, hLg);
+ SIC_IconAppend (swShell32Name, index, hSm, hLg);
}
- TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList);
+ TRACE("hIconSmall=%p hIconBig=%p\n", ShellSmallIconList, ShellBigIconList);
return TRUE;
}
@@ -317,29 +319,40 @@
UINT uFlags,
UINT * pIndex)
{
- IExtractIconA *ei;
- char szIconFile[MAX_PATH]; /* file containing the icon */
+ IExtractIconA *eia;
+ IExtractIconW *eiw;
+ WCHAR swIconFile[MAX_PATH]; /* file containing the icon */
INT iSourceIndex; /* index or resID(negated) in this file */
- BOOL ret = FALSE;
- UINT dwFlags = 0;
+ BOOL ret = FALSE;
+ UINT dwFlags = 0;
- TRACE("sf=%p pidl=%p %s\n", sh, pidl, bBigIcon?"Big":"Small");
+ TRACE("sf=%p pidl=%p %s\n", sh, pidl, bBigIcon ? "Big" : "Small");
- if (SUCCEEDED (IShellFolder_GetUIObjectOf(sh, 0, 1, &pidl, &IID_IExtractIconA, 0, (void **)&ei)))
+ if (SUCCEEDED (IShellFolder_GetUIObjectOf(sh, 0, 1, &pidl, &IID_IExtractIconW, 0, (void **)&eiw)))
{
- if (SUCCEEDED(IExtractIconA_GetIconLocation(ei, uFlags, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags)))
+ if (SUCCEEDED(IExtractIconW_GetIconLocation(eiw, uFlags, swIconFile, MAX_PATH, &iSourceIndex, &dwFlags)))
{
- *pIndex = SIC_GetIconIndex(szIconFile, iSourceIndex);
+ *pIndex = SIC_GetIconIndex(swIconFile, iSourceIndex);
ret = TRUE;
}
- IExtractIconA_Release(ei);
+ IExtractIconW_Release(eiw);
+ }
+ else if (SUCCEEDED (IShellFolder_GetUIObjectOf(sh, 0, 1, &pidl, &IID_IExtractIconA, 0, (void **)&eia)))
+ {
+ char szIconFile[MAX_PATH]; /* file containing the icon */
+ if (SUCCEEDED(IExtractIconA_GetIconLocation(eia, uFlags, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags)))
+ {
+ MultiByteToWideChar(CP_ACP, 0, szIconFile, -1, swIconFile, MAX_PATH);
+ *pIndex = SIC_GetIconIndex(swIconFile, iSourceIndex);
+ ret = TRUE;
+ }
+ IExtractIconA_Release(eia);
}
if (INVALID_INDEX == *pIndex) /* default icon when failed */
*pIndex = 1;
return ret;
-
}
/*************************************************************************
@@ -358,12 +371,12 @@
{
UINT Index;
- TRACE("(SF=%p,pidl=%p,%p)\n",sh,pidl,pIndex);
+ TRACE("(SF=%p,pidl=%p,%p)\n", sh, pidl, pIndex);
pdump(pidl);
+ PidlToSicIndex ( sh, pidl, TRUE, 0, &Index);
if (pIndex)
- PidlToSicIndex ( sh, pidl, 1, 0, pIndex);
- PidlToSicIndex ( sh, pidl, 0, 0, &Index);
+ *pIndex = Index;
return Index;
}
@@ -371,20 +384,22 @@
* Shell_GetCachedImageIndex [SHELL32.72]
*
*/
-INT WINAPI Shell_GetCachedImageIndexA(LPCSTR szPath, INT nIndex, BOOL bSimulateDoc)
+INT WINAPI Shell_GetCachedImageIndexW(LPCWSTR szPath, INT nIndex, BOOL bSimulateDoc)
{
- WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_a(szPath), nIndex, bSimulateDoc);
+ WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_w(szPath), nIndex, bSimulateDoc);
return SIC_GetIconIndex(szPath, nIndex);
}
-INT WINAPI Shell_GetCachedImageIndexW(LPCWSTR szPath, INT nIndex, BOOL bSimulateDoc)
-{ INT ret;
- LPSTR sTemp = HEAP_strdupWtoA (GetProcessHeap(),0,szPath);
+INT WINAPI Shell_GetCachedImageIndexA(LPCSTR szPath, INT nIndex, BOOL bSimulateDoc)
+{
+ INT ret, len = MultiByteToWideChar(CP_ACP, 0, szPath, -1, NULL, 0);
+ LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
- WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_w(szPath), nIndex, bSimulateDoc);
+ WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_a(szPath), nIndex, bSimulateDoc);
- ret = SIC_GetIconIndex(sTemp, nIndex);
- HeapFree(GetProcessHeap(),0,sTemp);
+ MultiByteToWideChar(CP_ACP, 0, szPath, -1, lpwstrFile, len);
+ ret = SIC_GetIconIndex(lpwstrFile, nIndex);
+ HeapFree(GetProcessHeap(), 0, lpwstrFile);
return ret;
}
More information about the wine-patches
mailing list