merge Wine commit:

- Mike McCormack <mike@codeweavers.com>
  Unicode-ify the icon cache and SHGetFileInfo.

- fix by M. Fuchs

svn path=/trunk/; revision=8841
This commit is contained in:
Martin Fuchs 2004-03-22 21:40:12 +00:00
parent d52dd4c5cc
commit e6bd3bc673
4 changed files with 99 additions and 86 deletions

View file

@ -151,7 +151,6 @@ static ULONG WINAPI IExtractIconW_fnRelease(IExtractIconW * iface)
} }
WCHAR swShell32Name[MAX_PATH]; WCHAR swShell32Name[MAX_PATH];
char sShell32Name[MAX_PATH];
/************************************************************************** /**************************************************************************
* IExtractIconW_GetIconLocation * IExtractIconW_GetIconLocation

View file

@ -53,7 +53,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
typedef struct 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 dwSourceIndex; /* index within the file, if it is a resoure ID it will be negated */
DWORD dwListIndex; /* index within the iconlist */ DWORD dwListIndex; /* index within the iconlist */
DWORD dwFlags; /* GIL_* flags */ DWORD dwFlags; /* GIL_* flags */
@ -83,7 +83,7 @@ static INT CALLBACK SIC_CompareEntries( LPVOID p1, LPVOID p2, LPARAM lparam)
if (((LPSIC_ENTRY)p1)->dwSourceIndex != ((LPSIC_ENTRY)p2)->dwSourceIndex) /* first the faster one*/ if (((LPSIC_ENTRY)p1)->dwSourceIndex != ((LPSIC_ENTRY)p2)->dwSourceIndex) /* first the faster one*/
return 1; return 1;
if (strcasecmp(((LPSIC_ENTRY)p1)->sSourceFile,((LPSIC_ENTRY)p2)->sSourceFile)) if (strcmpiW(((LPSIC_ENTRY)p1)->sSourceFile,((LPSIC_ENTRY)p2)->sSourceFile))
return 1; return 1;
return 0; return 0;
@ -94,17 +94,17 @@ static INT CALLBACK SIC_CompareEntries( LPVOID p1, LPVOID p2, LPARAM lparam)
* NOTES * NOTES
* appends an icon pair to the end of the cache * appends an 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; { LPSIC_ENTRY lpsice;
INT ret, index, index1; INT ret, index, index1;
char path[MAX_PATH]; WCHAR path[MAX_PATH];
TRACE("%s %i %p %p\n", sSourceFile, dwSourceIndex, hSmallIcon ,hBigIcon); TRACE("%s %i %p %p\n", debugstr_w(sSourceFile), dwSourceIndex, hSmallIcon ,hBigIcon);
lpsice = (LPSIC_ENTRY) SHAlloc (sizeof (SIC_ENTRY)); lpsice = (LPSIC_ENTRY) SHAlloc (sizeof (SIC_ENTRY));
GetFullPathNameA(sSourceFile, MAX_PATH, path, NULL); GetFullPathNameW(sSourceFile, MAX_PATH, path, NULL);
lpsice->sSourceFile = HeapAlloc( GetProcessHeap(), 0, strlen(path)+1 ); lpsice->sSourceFile = HeapAlloc( GetProcessHeap(), 0, (strlenW(path)+1)*sizeof(WCHAR) );
strcpy( lpsice->sSourceFile, path ); strcpyW( lpsice->sSourceFile, path );
lpsice->dwSourceIndex = dwSourceIndex; lpsice->dwSourceIndex = dwSourceIndex;
@ -139,30 +139,30 @@ static INT SIC_IconAppend (LPCSTR sSourceFile, INT dwSourceIndex, HICON hSmallIc
* NOTES * NOTES
* gets small/big icon by number from a file * 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 hiconLarge=0;
HICON hiconSmall=0; HICON hiconSmall=0;
#if defined(__CYGWIN__) || defined (__MINGW32__) || defined(_MSC_VER) #if defined(__CYGWIN__) || defined (__MINGW32__) || defined(_MSC_VER)
static UINT (WINAPI*PrivateExtractIconExA)(LPCSTR,int,HICON*,HICON*,UINT) = NULL; static UINT (WINAPI*PrivateExtractIconExW)(LPCWSTR,int,HICON*,HICON*,UINT) = NULL;
if (!PrivateExtractIconExA) { if (!PrivateExtractIconExW) {
HMODULE hUser32 = GetModuleHandleA("user32"); HMODULE hUser32 = GetModuleHandleA("user32");
PrivateExtractIconExA = (UINT(WINAPI*)(LPCSTR,int,HICON*,HICON*,UINT)) GetProcAddress(hUser32, "PrivateExtractIconExA"); PrivateExtractIconExW = (UINT(WINAPI*)(LPCWSTR,int,HICON*,HICON*,UINT)) GetProcAddress(hUser32, "PrivateExtractIconExW");
} }
if (PrivateExtractIconExA) if (PrivateExtractIconExW)
PrivateExtractIconExA(sSourceFile, dwSourceIndex, &hiconLarge, &hiconSmall, 1); PrivateExtractIconExW(sSourceFile, dwSourceIndex, &hiconLarge, &hiconSmall, 1);
else else
#endif #endif
{ {
PrivateExtractIconsA(sSourceFile, dwSourceIndex, 32, 32, &hiconLarge, NULL, 1, 0); PrivateExtractIconsW(sSourceFile, dwSourceIndex, 32, 32, &hiconLarge, NULL, 1, 0);
PrivateExtractIconsA(sSourceFile, dwSourceIndex, 16, 16, &hiconSmall, NULL, 1, 0); PrivateExtractIconsW(sSourceFile, dwSourceIndex, 16, 16, &hiconSmall, NULL, 1, 0);
} }
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 -1;
} }
return SIC_IconAppend (sSourceFile, dwSourceIndex, hiconSmall, hiconLarge); return SIC_IconAppend (sSourceFile, dwSourceIndex, hiconSmall, hiconLarge);
@ -178,14 +178,15 @@ static INT SIC_LoadIcon (LPCSTR sSourceFile, INT dwSourceIndex)
* look in the cache for a proper icon. if not available the icon is taken * look in the cache for a proper icon. if not available the icon is taken
* from the file and cached * from the file and cached
*/ */
INT SIC_GetIconIndex (LPCSTR sSourceFile, INT dwSourceIndex ) INT SIC_GetIconIndex (LPCWSTR sSourceFile, INT dwSourceIndex )
{ SIC_ENTRY sice; {
SIC_ENTRY sice;
INT ret, index = INVALID_INDEX; INT ret, index = INVALID_INDEX;
char path[MAX_PATH]; WCHAR path[MAX_PATH];
TRACE("%s %i\n", sSourceFile, dwSourceIndex); TRACE("%s %i\n", debugstr_w(sSourceFile), dwSourceIndex);
GetFullPathNameA(sSourceFile, MAX_PATH, path, NULL); GetFullPathNameW(sSourceFile, MAX_PATH, path, NULL);
sice.sSourceFile = path; sice.sSourceFile = path;
sice.dwSourceIndex = dwSourceIndex; sice.dwSourceIndex = dwSourceIndex;
@ -216,10 +217,10 @@ INT SIC_GetIconIndex (LPCSTR sSourceFile, INT dwSourceIndex )
* NOTES * NOTES
* retrieves the specified icon from the iconcache. * retrieves the specified icon from the iconcache.
*/ */
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; { INT index;
TRACE("%s %i\n", sSourceFile, dwSourceIndex); TRACE("%s %i\n", debugstr_w(sSourceFile), dwSourceIndex);
index = SIC_GetIconIndex(sSourceFile, dwSourceIndex); index = SIC_GetIconIndex(sSourceFile, dwSourceIndex);
@ -280,7 +281,7 @@ BOOL SIC_Initialize(void)
hSm = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(1), IMAGE_ICON, cx_small, cy_small, LR_SHARED); hSm = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(1), IMAGE_ICON, cx_small, cy_small, LR_SHARED);
hLg = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(1), IMAGE_ICON, cx_large, cy_large, LR_SHARED); hLg = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(1), IMAGE_ICON, cx_large, cy_large, LR_SHARED);
} }
SIC_IconAppend (sShell32Name, 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);
@ -349,22 +350,22 @@ BOOL PidlToSicIndex (
UINT uFlags, UINT uFlags,
int * pIndex) int * pIndex)
{ {
IExtractIconA *ei; IExtractIconW *ei;
char szIconFile[MAX_PATH]; /* file containing the icon */ WCHAR szIconFile[MAX_PATH]; /* file containing the icon */
INT iSourceIndex; /* index or resID(negated) in this file */ INT iSourceIndex; /* index or resID(negated) in this file */
BOOL ret = FALSE; BOOL ret = FALSE;
UINT dwFlags = 0; 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 **)&ei)))
{ {
if (SUCCEEDED(IExtractIconA_GetIconLocation(ei, uFlags, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags))) if (SUCCEEDED(IExtractIconW_GetIconLocation(ei, uFlags, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags)))
{ {
*pIndex = SIC_GetIconIndex(szIconFile, iSourceIndex); *pIndex = SIC_GetIconIndex(szIconFile, iSourceIndex);
ret = TRUE; ret = TRUE;
} }
IExtractIconA_Release(ei); IExtractIconW_Release(ei);
} }
if (INVALID_INDEX == *pIndex) /* default icon when failed */ if (INVALID_INDEX == *pIndex) /* default icon when failed */
@ -408,19 +409,27 @@ int WINAPI SHMapPIDLToSystemImageListIndex(
*/ */
INT WINAPI Shell_GetCachedImageIndexA(LPCSTR szPath, INT nIndex, BOOL bSimulateDoc) INT WINAPI Shell_GetCachedImageIndexA(LPCSTR szPath, INT nIndex, BOOL bSimulateDoc)
{ {
INT ret, len;
LPWSTR szTemp;
WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_a(szPath), nIndex, bSimulateDoc); WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_a(szPath), nIndex, bSimulateDoc);
return SIC_GetIconIndex(szPath, nIndex);
len = MultiByteToWideChar( CP_ACP, 0, szPath, -1, NULL, 0 );
szTemp = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, szPath, -1, szTemp, len );
ret = SIC_GetIconIndex( szTemp, nIndex );
HeapFree( GetProcessHeap(), 0, szTemp );
return ret;
} }
INT WINAPI Shell_GetCachedImageIndexW(LPCWSTR szPath, INT nIndex, BOOL bSimulateDoc) INT WINAPI Shell_GetCachedImageIndexW(LPCWSTR szPath, INT nIndex, BOOL bSimulateDoc)
{ INT ret; {
LPSTR sTemp = HEAP_strdupWtoA (GetProcessHeap(),0,szPath);
WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_w(szPath), nIndex, bSimulateDoc); WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_w(szPath), nIndex, bSimulateDoc);
ret = SIC_GetIconIndex(sTemp, nIndex); return SIC_GetIconIndex(szPath, nIndex);
HeapFree(GetProcessHeap(),0,sTemp);
return ret;
} }
INT WINAPI Shell_GetCachedImageIndexAW(LPCVOID szPath, INT nIndex, BOOL bSimulateDoc) INT WINAPI Shell_GetCachedImageIndexAW(LPCVOID szPath, INT nIndex, BOOL bSimulateDoc)

View file

@ -208,21 +208,21 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
* *
*/ */
DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes, DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
SHFILEINFOA *psfi, UINT sizeofpsfi, SHFILEINFOW *psfi, UINT sizeofpsfi,
UINT flags ) UINT flags )
{ {
char szLocation[MAX_PATH], szFullPath[MAX_PATH]; WCHAR szLocation[MAX_PATH], szFullPath[MAX_PATH];
int iIndex; int iIndex;
DWORD ret = TRUE, dwAttributes = 0; DWORD ret = TRUE, dwAttributes = 0;
IShellFolder * psfParent = NULL; IShellFolder * psfParent = NULL;
IExtractIconA * pei = NULL; IExtractIconW * pei = NULL;
LPITEMIDLIST pidlLast = NULL, pidl = NULL; LPITEMIDLIST pidlLast = NULL, pidl = NULL;
HRESULT hr = S_OK; 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", 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; return FALSE;
@ -236,11 +236,11 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
if (!(flags & SHGFI_PIDL)){ if (!(flags & SHGFI_PIDL)){
/* SHGitFileInfo should work with absolute and relative paths */ /* SHGitFileInfo should work with absolute and relative paths */
if (PathIsRelativeA(path)){ if (PathIsRelativeW(path)){
GetCurrentDirectoryA(MAX_PATH, szLocation); GetCurrentDirectoryW(MAX_PATH, szLocation);
PathCombineA(szFullPath, szLocation, path); PathCombineW(szFullPath, szLocation, path);
} else { } else {
lstrcpynA(szFullPath, path, MAX_PATH); lstrcpynW(szFullPath, path, MAX_PATH);
} }
} }
@ -255,12 +255,12 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
if (flags != SHGFI_EXETYPE) return 0; if (flags != SHGFI_EXETYPE) return 0;
status = GetBinaryTypeA (szFullPath, &BinaryType); status = GetBinaryTypeW (szFullPath, &BinaryType);
if (!status) return 0; if (!status) return 0;
if ((BinaryType == SCS_DOS_BINARY) if ((BinaryType == SCS_DOS_BINARY)
|| (BinaryType == SCS_PIF_BINARY)) return 0x4d5a; || (BinaryType == SCS_PIF_BINARY)) return 0x4d5a;
hfile = CreateFileA( szFullPath, GENERIC_READ, FILE_SHARE_READ, hfile = CreateFileW( szFullPath, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, 0 ); NULL, OPEN_EXISTING, 0, 0 );
if ( hfile == INVALID_HANDLE_VALUE ) return 0; if ( hfile == INVALID_HANDLE_VALUE ) return 0;
@ -313,7 +313,7 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
if (flags & SHGFI_PIDL) { if (flags & SHGFI_PIDL) {
pidl = ILClone((LPCITEMIDLIST)path); pidl = ILClone((LPCITEMIDLIST)path);
} else if (!(flags & SHGFI_USEFILEATTRIBUTES)) { } else if (!(flags & SHGFI_USEFILEATTRIBUTES)) {
hr = SHILCreateFromPathA(szFullPath, &pidl, &dwAttributes); hr = SHILCreateFromPathW(szFullPath, &pidl, &dwAttributes);
} }
if ((flags & SHGFI_PIDL) || !(flags & SHGFI_USEFILEATTRIBUTES)) if ((flags & SHGFI_PIDL) || !(flags & SHGFI_USEFILEATTRIBUTES))
@ -343,34 +343,40 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
{ {
if (flags & SHGFI_USEFILEATTRIBUTES) if (flags & SHGFI_USEFILEATTRIBUTES)
{ {
strcpy (psfi->szDisplayName, PathFindFileNameA(szFullPath)); lstrcpyW (psfi->szDisplayName, PathFindFileNameW(szFullPath));
} }
else else
{ {
STRRET str; STRRET str;
hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &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 */ /* get the type name */
if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME)) if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
{ {
WCHAR szFile[] = { 'F','i','l','e',0 };
WCHAR szDashFile[] = { '-','f','i','l','e',0 };
if (!(flags & SHGFI_USEFILEATTRIBUTES)) if (!(flags & SHGFI_USEFILEATTRIBUTES))
_ILGetFileType(pidlLast, psfi->szTypeName, 80); {
char ftype[80];
_ILGetFileType(pidlLast, ftype, 80);
MultiByteToWideChar(CP_ACP, 0, ftype, -1, psfi->szTypeName, 80 );
}
else else
{ {
if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
strcat (psfi->szTypeName, "File"); strcatW (psfi->szTypeName, szFile);
else else
{ {
char sTemp[64]; WCHAR sTemp[64];
strcpy(sTemp,PathFindExtensionA(szFullPath)); lstrcpyW(sTemp,PathFindExtensionW(szFullPath));
if (!( HCR_MapTypeToValueA(sTemp, sTemp, 64, TRUE) if (!( HCR_MapTypeToValueW(sTemp, sTemp, 64, TRUE)
&& HCR_MapTypeToValueA(sTemp, psfi->szTypeName, 80, FALSE ))) && HCR_MapTypeToValueW(sTemp, psfi->szTypeName, 80, FALSE )))
{ {
lstrcpynA (psfi->szTypeName, sTemp, 64); lstrcpynW (psfi->szTypeName, sTemp, 64);
strcat (psfi->szTypeName, "-file"); strcatW (psfi->szTypeName, szDashFile);
} }
} }
} }
@ -394,11 +400,11 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
hr = IExtractIconA_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLocation, MAX_PATH, &iIndex, &uFlags); hr = IExtractIconW_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLocation, MAX_PATH, &iIndex, &uFlags);
psfi->iIcon = iIndex; psfi->iIcon = iIndex;
if(uFlags != GIL_NOTFILENAME) if(uFlags != GIL_NOTFILENAME)
strcpy (psfi->szDisplayName, szLocation); lstrcpyW (psfi->szDisplayName, szLocation);
else else
ret = FALSE; ret = FALSE;
@ -412,23 +418,24 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
if (flags & SHGFI_USEFILEATTRIBUTES) if (flags & SHGFI_USEFILEATTRIBUTES)
{ {
char sTemp [MAX_PATH]; WCHAR sTemp [MAX_PATH];
char * szExt; WCHAR * szExt;
DWORD dwNr=0; DWORD dwNr=0;
lstrcpynA(sTemp, szFullPath, MAX_PATH); lstrcpynW(sTemp, szFullPath, MAX_PATH);
if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
psfi->iIcon = 2; psfi->iIcon = 2;
else else
{ {
WCHAR p1W[] = {'%','1',0};
psfi->iIcon = 0; psfi->iIcon = 0;
szExt = (LPSTR) PathFindExtensionA(sTemp); szExt = (LPWSTR) PathFindExtensionW(sTemp);
if ( szExt && HCR_MapTypeToValueA(szExt, sTemp, MAX_PATH, TRUE) if ( szExt && HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE)
&& HCR_GetDefaultIconA(sTemp, sTemp, MAX_PATH, &dwNr)) && HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &dwNr))
{ {
if (!strcmp("%1",sTemp)) /* icon is in the file */ if (!lstrcmpW(p1W,sTemp)) /* icon is in the file */
strcpy(sTemp, szFullPath); strcpyW(sTemp, szFullPath);
if (flags & SHGFI_SYSICONINDEX) if (flags & SHGFI_SYSICONINDEX)
{ {
@ -438,7 +445,7 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
else else
{ {
IconNotYetLoaded=FALSE; IconNotYetLoaded=FALSE;
PrivateExtractIconsA(sTemp,dwNr,(flags & SHGFI_SMALLICON) ? PrivateExtractIconsW(sTemp,dwNr,(flags & SHGFI_SMALLICON) ?
GetSystemMetrics(SM_CXSMICON) : GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CXSMICON) : GetSystemMetrics(SM_CXICON),
(flags & SHGFI_SMALLICON) ? GetSystemMetrics(SM_CYSMICON) : (flags & SHGFI_SMALLICON) ? GetSystemMetrics(SM_CYSMICON) :
GetSystemMetrics(SM_CYICON), &psfi->hIcon,0,1,0); GetSystemMetrics(SM_CYICON), &psfi->hIcon,0,1,0);
@ -477,7 +484,7 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
if(pidlLast) SHFree(pidlLast); if(pidlLast) SHFree(pidlLast);
#ifdef MORE_DEBUG #ifdef MORE_DEBUG
TRACE ("icon=%p index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n", TRACE ("icon=%p index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
psfi->hIcon, psfi->iIcon, psfi->dwAttributes, psfi->szDisplayName, psfi->szTypeName, ret); psfi->hIcon, psfi->iIcon, psfi->dwAttributes, debugstr_w(psfi->szDisplayName), debugstr_w(psfi->szTypeName), ret);
#endif #endif
return ret; return ret;
} }
@ -486,28 +493,28 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
* SHGetFileInfoW [SHELL32.@] * SHGetFileInfoW [SHELL32.@]
*/ */
DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
SHFILEINFOW *psfi, UINT sizeofpsfi, SHFILEINFOA *psfi, UINT sizeofpsfi,
UINT flags ) UINT flags )
{ {
INT len; INT len;
LPSTR temppath; LPWSTR temppath;
DWORD ret; DWORD ret;
SHFILEINFOA temppsfi; SHFILEINFOW temppsfi;
if (flags & SHGFI_PIDL) { if (flags & SHGFI_PIDL) {
/* path contains a pidl */ /* path contains a pidl */
temppath = (LPSTR) path; temppath = (LPWSTR) path;
} else { } else {
len = WideCharToMultiByte(CP_ACP, 0, path, -1, NULL, 0, NULL, NULL); len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
temppath = HeapAlloc(GetProcessHeap(), 0, len); temppath = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
WideCharToMultiByte(CP_ACP, 0, path, -1, temppath, len, NULL, NULL); MultiByteToWideChar(CP_ACP, 0, path, -1, temppath, len);
} }
if(psfi && (flags & SHGFI_ATTR_SPECIFIED)) if(psfi && (flags & SHGFI_ATTR_SPECIFIED))
temppsfi.dwAttributes=psfi->dwAttributes; temppsfi.dwAttributes=psfi->dwAttributes;
ret = SHGetFileInfoA(temppath, dwFileAttributes, (psfi == NULL)? NULL : &temppsfi, sizeof(temppsfi), flags); ret = SHGetFileInfoW(temppath, dwFileAttributes, (psfi == NULL)? NULL : &temppsfi, sizeof(temppsfi), flags);
if (psfi) if (psfi)
{ {
@ -518,9 +525,9 @@ DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
if(flags & SHGFI_ATTRIBUTES) if(flags & SHGFI_ATTRIBUTES)
psfi->dwAttributes=temppsfi.dwAttributes; psfi->dwAttributes=temppsfi.dwAttributes;
if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION)) if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION))
MultiByteToWideChar(CP_ACP, 0, temppsfi.szDisplayName, -1, psfi->szDisplayName, sizeof(psfi->szDisplayName)); WideCharToMultiByte(CP_ACP, 0, temppsfi.szDisplayName, -1, psfi->szDisplayName, sizeof(psfi->szDisplayName), NULL, NULL);
if(flags & SHGFI_TYPENAME) if(flags & SHGFI_TYPENAME)
MultiByteToWideChar(CP_ACP, 0, temppsfi.szTypeName, -1, psfi->szTypeName, sizeof(psfi->szTypeName)); WideCharToMultiByte(CP_ACP, 0, temppsfi.szTypeName, -1, psfi->szTypeName, sizeof(psfi->szTypeName), NULL, NULL);
} }
if(!(flags & SHGFI_PIDL)) HeapFree(GetProcessHeap(), 0, temppath); if(!(flags & SHGFI_PIDL)) HeapFree(GetProcessHeap(), 0, temppath);
return ret; return ret;
@ -916,7 +923,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
/* get full path to this DLL for IExtractIconW_fnGetIconLocation() */ /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */
GetModuleFileNameW(hinstDLL, swShell32Name, MAX_PATH); GetModuleFileNameW(hinstDLL, swShell32Name, MAX_PATH);
WideCharToMultiByte(CP_ACP, 0, swShell32Name, -1, sShell32Name, MAX_PATH, NULL, NULL);
InitCommonControlsEx(NULL); InitCommonControlsEx(NULL);

View file

@ -53,7 +53,7 @@ BOOL WINAPI Shell_GetImageList(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList)
BOOL SIC_Initialize(void); BOOL SIC_Initialize(void);
void SIC_Destroy(void); void SIC_Destroy(void);
BOOL PidlToSicIndex (IShellFolder * sh, LPCITEMIDLIST pidl, BOOL bBigIcon, UINT uFlags, int * pIndex); BOOL PidlToSicIndex (IShellFolder * sh, LPCITEMIDLIST pidl, BOOL bBigIcon, UINT uFlags, int * pIndex);
INT SIC_GetIconIndex (LPCSTR sSourceFile, INT dwSourceIndex ); INT SIC_GetIconIndex (LPCWSTR sSourceFile, INT dwSourceIndex );
/* Classes Root */ /* Classes Root */
BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, DWORD len, BOOL bPrependDot); BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, DWORD len, BOOL bPrependDot);
@ -248,6 +248,5 @@ int WINAPI RestartDialog(HWND hwndOwner, LPCSTR lpstrReason, UINT uFlags);
int WINAPI RestartDialogEx(HWND hwndOwner, LPCWSTR lpwstrReason, UINT uFlags, UINT uReason); int WINAPI RestartDialogEx(HWND hwndOwner, LPCWSTR lpwstrReason, UINT uFlags, UINT uReason);
extern WCHAR swShell32Name[MAX_PATH]; extern WCHAR swShell32Name[MAX_PATH];
extern char sShell32Name[MAX_PATH];
#endif #endif