1998-11-15 13:25:18 +00:00
|
|
|
/*
|
|
|
|
* shell icon cache (SIC)
|
|
|
|
*
|
2002-03-09 23:29:33 +00:00
|
|
|
* Copyright 1998, 1999 Juergen Schmied
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1998-11-15 13:25:18 +00:00
|
|
|
*/
|
2002-03-09 23:29:33 +00:00
|
|
|
|
2002-08-17 00:43:16 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
1998-11-15 13:25:18 +00:00
|
|
|
#include <string.h>
|
2000-02-10 19:03:02 +00:00
|
|
|
#include <sys/types.h>
|
2002-08-17 00:43:16 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2000-02-10 19:03:02 +00:00
|
|
|
#include "windef.h"
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "winbase.h"
|
2000-02-10 19:03:02 +00:00
|
|
|
#include "wingdi.h"
|
1999-05-22 11:33:23 +00:00
|
|
|
#include "winuser.h"
|
2001-11-06 22:31:19 +00:00
|
|
|
#include "winreg.h"
|
1999-01-01 18:57:33 +00:00
|
|
|
#include "wine/winuser16.h"
|
1999-02-17 13:51:06 +00:00
|
|
|
#include "wine/winbase16.h"
|
1998-11-15 13:25:18 +00:00
|
|
|
#include "heap.h"
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
1999-04-22 10:11:04 +00:00
|
|
|
|
|
|
|
#include "shellapi.h"
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "objbase.h"
|
2000-08-03 04:19:24 +00:00
|
|
|
#include "shlguid.h"
|
1998-11-15 13:25:18 +00:00
|
|
|
#include "pidl.h"
|
|
|
|
#include "shell32_main.h"
|
2001-08-16 18:49:56 +00:00
|
|
|
#include "undocshell.h"
|
2000-04-28 20:18:15 +00:00
|
|
|
#include "shlwapi.h"
|
1998-11-15 13:25:18 +00:00
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
1998-11-15 13:25:18 +00:00
|
|
|
|
|
|
|
/********************** THE ICON CACHE ********************************/
|
|
|
|
|
1998-12-14 17:37:38 +00:00
|
|
|
#define INVALID_INDEX -1
|
|
|
|
|
1998-11-15 13:25:18 +00:00
|
|
|
typedef struct
|
2001-07-24 21:45:22 +00:00
|
|
|
{
|
|
|
|
LPSTR sSourceFile; /* file (not path!) containing the icon */
|
1999-04-11 11:50:41 +00:00
|
|
|
DWORD dwSourceIndex; /* index within the file, if it is a resoure ID it will be negated */
|
1998-11-15 13:25:18 +00:00
|
|
|
DWORD dwListIndex; /* index within the iconlist */
|
1999-04-11 11:50:41 +00:00
|
|
|
DWORD dwFlags; /* GIL_* flags */
|
|
|
|
DWORD dwAccessTime;
|
1998-11-15 13:25:18 +00:00
|
|
|
} SIC_ENTRY, * LPSIC_ENTRY;
|
|
|
|
|
1999-08-15 14:26:30 +00:00
|
|
|
static HDPA sic_hdpa = 0;
|
2003-08-12 23:50:54 +00:00
|
|
|
|
|
|
|
static CRITICAL_SECTION SHELL32_SicCS;
|
|
|
|
static CRITICAL_SECTION_DEBUG critsect_debug =
|
|
|
|
{
|
|
|
|
0, 0, &SHELL32_SicCS,
|
|
|
|
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
|
|
|
0, 0, { 0, (DWORD)(__FILE__ ": SHELL32_SicCS") }
|
|
|
|
};
|
|
|
|
static CRITICAL_SECTION SHELL32_SicCS = { &critsect_debug, -1, 0, 0, 0, 0 };
|
1999-08-15 14:26:30 +00:00
|
|
|
|
1998-11-15 13:25:18 +00:00
|
|
|
/*****************************************************************************
|
2001-11-06 00:45:32 +00:00
|
|
|
* SIC_CompareEntries
|
1999-03-13 17:10:36 +00:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Callback for DPA_Search
|
|
|
|
*/
|
2001-11-06 00:45:32 +00:00
|
|
|
static INT CALLBACK SIC_CompareEntries( LPVOID p1, LPVOID p2, LPARAM lparam)
|
2002-04-11 21:47:53 +00:00
|
|
|
{ TRACE("%p %p %8lx\n", p1, p2, lparam);
|
1998-11-15 13:25:18 +00:00
|
|
|
|
|
|
|
if (((LPSIC_ENTRY)p1)->dwSourceIndex != ((LPSIC_ENTRY)p2)->dwSourceIndex) /* first the faster one*/
|
|
|
|
return 1;
|
|
|
|
|
1998-12-14 17:37:38 +00:00
|
|
|
if (strcasecmp(((LPSIC_ENTRY)p1)->sSourceFile,((LPSIC_ENTRY)p2)->sSourceFile))
|
1998-11-15 13:25:18 +00:00
|
|
|
return 1;
|
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
return 0;
|
1998-11-15 13:25:18 +00:00
|
|
|
}
|
|
|
|
/*****************************************************************************
|
1999-03-13 17:10:36 +00:00
|
|
|
* SIC_IconAppend [internal]
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* appends a icon pair to the end of the cache
|
|
|
|
*/
|
1999-02-26 11:11:13 +00:00
|
|
|
static INT SIC_IconAppend (LPCSTR sSourceFile, INT dwSourceIndex, HICON hSmallIcon, HICON hBigIcon)
|
1998-11-15 13:25:18 +00:00
|
|
|
{ LPSIC_ENTRY lpsice;
|
1999-08-15 14:26:30 +00:00
|
|
|
INT ret, index, index1;
|
2001-07-24 21:45:22 +00:00
|
|
|
char *path;
|
2002-11-21 23:56:42 +00:00
|
|
|
TRACE("%s %i %p %p\n", sSourceFile, dwSourceIndex, hSmallIcon ,hBigIcon);
|
1998-11-15 13:25:18 +00:00
|
|
|
|
|
|
|
lpsice = (LPSIC_ENTRY) SHAlloc (sizeof (SIC_ENTRY));
|
|
|
|
|
2001-07-24 21:45:22 +00:00
|
|
|
path = PathFindFileNameA(sSourceFile);
|
|
|
|
lpsice->sSourceFile = HeapAlloc( GetProcessHeap(), 0, strlen(path)+1 );
|
|
|
|
strcpy( lpsice->sSourceFile, path );
|
|
|
|
|
1998-11-15 13:25:18 +00:00
|
|
|
lpsice->dwSourceIndex = dwSourceIndex;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-08-15 14:26:30 +00:00
|
|
|
EnterCriticalSection(&SHELL32_SicCS);
|
|
|
|
|
2002-07-29 00:24:58 +00:00
|
|
|
index = DPA_InsertPtr(sic_hdpa, 0x7fff, lpsice);
|
1998-12-14 17:37:38 +00:00
|
|
|
if ( INVALID_INDEX == index )
|
1999-08-15 14:26:30 +00:00
|
|
|
{
|
|
|
|
SHFree(lpsice);
|
|
|
|
ret = INVALID_INDEX;
|
1999-03-13 17:10:36 +00:00
|
|
|
}
|
1999-08-15 14:26:30 +00:00
|
|
|
else
|
|
|
|
{
|
2001-01-17 22:05:24 +00:00
|
|
|
index = ImageList_AddIcon (ShellSmallIconList, hSmallIcon);
|
|
|
|
index1= ImageList_AddIcon (ShellBigIconList, hBigIcon);
|
1998-11-15 13:25:18 +00:00
|
|
|
|
1999-08-15 14:26:30 +00:00
|
|
|
if (index!=index1)
|
|
|
|
{
|
|
|
|
FIXME("iconlists out of sync 0x%x 0x%x\n", index, index1);
|
|
|
|
}
|
|
|
|
lpsice->dwListIndex = index;
|
|
|
|
ret = lpsice->dwListIndex;
|
1998-12-14 17:37:38 +00:00
|
|
|
}
|
1999-08-15 14:26:30 +00:00
|
|
|
|
|
|
|
LeaveCriticalSection(&SHELL32_SicCS);
|
2002-05-31 23:06:46 +00:00
|
|
|
return ret;
|
1998-11-15 13:25:18 +00:00
|
|
|
}
|
1998-12-14 17:37:38 +00:00
|
|
|
/****************************************************************************
|
1999-03-13 17:10:36 +00:00
|
|
|
* SIC_LoadIcon [internal]
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* gets small/big icon by number from a file
|
|
|
|
*/
|
1999-02-26 11:11:13 +00:00
|
|
|
static INT SIC_LoadIcon (LPCSTR sSourceFile, INT dwSourceIndex)
|
|
|
|
{ HICON hiconLarge=0;
|
|
|
|
HICON hiconSmall=0;
|
1998-12-14 17:37:38 +00:00
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
PrivateExtractIconsA( sSourceFile, dwSourceIndex, 32, 32, &hiconLarge, 0, 1, 0 );
|
|
|
|
PrivateExtractIconsA( sSourceFile, dwSourceIndex, 16, 16, &hiconSmall, 0, 1, 0 );
|
1998-12-14 17:37:38 +00:00
|
|
|
|
|
|
|
if ( !hiconLarge || !hiconSmall)
|
1999-08-15 14:26:30 +00:00
|
|
|
{
|
2002-11-21 23:56:42 +00:00
|
|
|
WARN("failure loading icon %i from %s (%p %p)\n", dwSourceIndex, sSourceFile, hiconLarge, hiconSmall);
|
1998-12-14 17:37:38 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
return SIC_IconAppend (sSourceFile, dwSourceIndex, hiconSmall, hiconLarge);
|
1998-12-14 17:37:38 +00:00
|
|
|
}
|
1998-11-15 13:25:18 +00:00
|
|
|
/*****************************************************************************
|
1999-03-13 17:10:36 +00:00
|
|
|
* SIC_GetIconIndex [internal]
|
|
|
|
*
|
1999-04-11 11:50:41 +00:00
|
|
|
* Parameters
|
|
|
|
* sSourceFile [IN] filename of file containing the icon
|
|
|
|
* index [IN] index/resID (negated) in this file
|
|
|
|
*
|
1999-03-13 17:10:36 +00:00
|
|
|
* NOTES
|
|
|
|
* look in the cache for a proper icon. if not available the icon is taken
|
|
|
|
* from the file and cached
|
|
|
|
*/
|
1999-02-26 11:11:13 +00:00
|
|
|
INT SIC_GetIconIndex (LPCSTR sSourceFile, INT dwSourceIndex )
|
1998-12-14 17:37:38 +00:00
|
|
|
{ SIC_ENTRY sice;
|
1999-08-15 14:26:30 +00:00
|
|
|
INT ret, index = INVALID_INDEX;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("%s %i\n", sSourceFile, dwSourceIndex);
|
1998-11-15 13:25:18 +00:00
|
|
|
|
2000-04-28 20:18:15 +00:00
|
|
|
sice.sSourceFile = PathFindFileNameA(sSourceFile);
|
1998-12-14 17:37:38 +00:00
|
|
|
sice.dwSourceIndex = dwSourceIndex;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-08-15 14:26:30 +00:00
|
|
|
EnterCriticalSection(&SHELL32_SicCS);
|
|
|
|
|
2002-07-29 00:24:58 +00:00
|
|
|
if (NULL != DPA_GetPtr (sic_hdpa, 0))
|
1999-08-15 14:26:30 +00:00
|
|
|
{
|
2002-04-11 21:47:53 +00:00
|
|
|
/* search linear from position 0*/
|
2002-07-29 00:24:58 +00:00
|
|
|
index = DPA_Search (sic_hdpa, &sice, 0, SIC_CompareEntries, 0, 0);
|
1998-12-24 14:33:29 +00:00
|
|
|
}
|
1998-11-15 13:25:18 +00:00
|
|
|
|
1998-12-14 17:37:38 +00:00
|
|
|
if ( INVALID_INDEX == index )
|
1999-08-15 14:26:30 +00:00
|
|
|
{
|
|
|
|
ret = SIC_LoadIcon (sSourceFile, dwSourceIndex);
|
1998-12-14 17:37:38 +00:00
|
|
|
}
|
1999-08-15 14:26:30 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("-- found\n");
|
2002-07-29 00:24:58 +00:00
|
|
|
ret = ((LPSIC_ENTRY)DPA_GetPtr(sic_hdpa, index))->dwListIndex;
|
1999-08-15 14:26:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&SHELL32_SicCS);
|
|
|
|
return ret;
|
1998-12-14 17:37:38 +00:00
|
|
|
}
|
|
|
|
/****************************************************************************
|
2001-02-23 01:12:26 +00:00
|
|
|
* SIC_GetIcon [internal]
|
1999-03-13 17:10:36 +00:00
|
|
|
*
|
|
|
|
* NOTES
|
2001-11-06 21:01:32 +00:00
|
|
|
* retrieves the specified icon from the iconcache. if not found tries to load the icon
|
1999-03-13 17:10:36 +00:00
|
|
|
*/
|
1999-03-18 17:39:57 +00:00
|
|
|
static HICON WINE_UNUSED SIC_GetIcon (LPCSTR sSourceFile, INT dwSourceIndex, BOOL bSmallIcon )
|
1999-02-26 11:11:13 +00:00
|
|
|
{ INT index;
|
1998-11-15 13:25:18 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("%s %i\n", sSourceFile, dwSourceIndex);
|
1998-11-15 13:25:18 +00:00
|
|
|
|
1998-12-14 17:37:38 +00:00
|
|
|
index = SIC_GetIconIndex(sSourceFile, dwSourceIndex);
|
1999-08-15 14:26:30 +00:00
|
|
|
|
1998-12-14 17:37:38 +00:00
|
|
|
if (INVALID_INDEX == index)
|
1999-08-15 14:26:30 +00:00
|
|
|
{
|
2002-10-10 21:22:09 +00:00
|
|
|
return (HICON)INVALID_INDEX;
|
1998-11-15 13:25:18 +00:00
|
|
|
}
|
|
|
|
|
1998-12-14 17:37:38 +00:00
|
|
|
if (bSmallIcon)
|
2001-01-17 22:05:24 +00:00
|
|
|
return ImageList_GetIcon(ShellSmallIconList, index, ILD_NORMAL);
|
|
|
|
return ImageList_GetIcon(ShellBigIconList, index, ILD_NORMAL);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1998-11-15 13:25:18 +00:00
|
|
|
}
|
|
|
|
/*****************************************************************************
|
1999-03-13 17:10:36 +00:00
|
|
|
* SIC_Initialize [internal]
|
|
|
|
*
|
|
|
|
* NOTES
|
2002-05-31 23:06:46 +00:00
|
|
|
* hack to load the resources from the shell32.dll under a different dll name
|
1999-03-13 17:10:36 +00:00
|
|
|
* will be removed when the resource-compiler is ready
|
|
|
|
*/
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL SIC_Initialize(void)
|
1999-08-15 14:26:30 +00:00
|
|
|
{
|
|
|
|
HICON hSm, hLg;
|
1999-02-26 11:11:13 +00:00
|
|
|
UINT index;
|
1999-04-11 11:50:41 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("\n");
|
1998-11-15 13:25:18 +00:00
|
|
|
|
1999-07-10 11:50:54 +00:00
|
|
|
if (sic_hdpa) /* already initialized?*/
|
1998-11-15 13:25:18 +00:00
|
|
|
return TRUE;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2002-07-29 00:24:58 +00:00
|
|
|
sic_hdpa = DPA_Create(16);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-07-10 11:50:54 +00:00
|
|
|
if (!sic_hdpa)
|
1999-08-15 14:26:30 +00:00
|
|
|
{
|
|
|
|
return(FALSE);
|
1998-11-15 13:25:18 +00:00
|
|
|
}
|
|
|
|
|
2001-01-17 22:05:24 +00:00
|
|
|
ShellSmallIconList = ImageList_Create(16,16,ILC_COLORDDB | ILC_MASK,0,0x20);
|
|
|
|
ShellBigIconList = ImageList_Create(32,32,ILC_COLORDDB | ILC_MASK,0,0x20);
|
1998-11-15 13:25:18 +00:00
|
|
|
|
2001-01-17 22:05:24 +00:00
|
|
|
ImageList_SetBkColor(ShellSmallIconList, GetSysColor(COLOR_WINDOW));
|
|
|
|
ImageList_SetBkColor(ShellBigIconList, GetSysColor(COLOR_WINDOW));
|
1999-07-25 12:21:24 +00:00
|
|
|
|
1999-08-15 14:26:30 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
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);
|
1998-11-15 13:25:18 +00:00
|
|
|
}
|
1999-08-15 14:26:30 +00:00
|
|
|
SIC_IconAppend ("shell32.dll", index, hSm, hLg);
|
1998-11-15 13:25:18 +00:00
|
|
|
}
|
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList);
|
1998-11-15 13:25:18 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-03-28 12:35:24 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* SIC_Destroy
|
|
|
|
*
|
|
|
|
* frees the cache
|
|
|
|
*/
|
2003-09-17 20:15:21 +00:00
|
|
|
static INT CALLBACK sic_free( LPVOID ptr, LPVOID lparam )
|
1999-03-28 12:35:24 +00:00
|
|
|
{
|
2003-09-17 20:15:21 +00:00
|
|
|
SHFree(ptr);
|
|
|
|
return TRUE;
|
|
|
|
}
|
1998-11-15 13:25:18 +00:00
|
|
|
|
2003-09-17 20:15:21 +00:00
|
|
|
void SIC_Destroy(void)
|
|
|
|
{
|
1999-07-10 11:50:54 +00:00
|
|
|
TRACE("\n");
|
|
|
|
|
1999-08-15 14:26:30 +00:00
|
|
|
EnterCriticalSection(&SHELL32_SicCS);
|
|
|
|
|
2003-09-17 20:15:21 +00:00
|
|
|
if (sic_hdpa) DPA_DestroyCallback(sic_hdpa, sic_free, NULL );
|
1999-07-10 11:50:54 +00:00
|
|
|
|
|
|
|
sic_hdpa = NULL;
|
1999-08-15 14:26:30 +00:00
|
|
|
|
|
|
|
LeaveCriticalSection(&SHELL32_SicCS);
|
2000-02-26 18:47:23 +00:00
|
|
|
DeleteCriticalSection(&SHELL32_SicCS);
|
1999-03-28 12:35:24 +00:00
|
|
|
}
|
1998-11-15 13:25:18 +00:00
|
|
|
/*************************************************************************
|
1999-03-13 17:10:36 +00:00
|
|
|
* Shell_GetImageList [SHELL32.71]
|
1998-11-15 13:25:18 +00:00
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* imglist[1|2] [OUT] pointer which recive imagelist handles
|
|
|
|
*
|
|
|
|
*/
|
1999-04-11 11:50:41 +00:00
|
|
|
BOOL WINAPI Shell_GetImageList(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList)
|
1999-06-12 15:45:58 +00:00
|
|
|
{ TRACE("(%p,%p)\n",lpBigList,lpSmallList);
|
1999-01-26 10:37:57 +00:00
|
|
|
if (lpBigList)
|
|
|
|
{ *lpBigList = ShellBigIconList;
|
1998-11-15 13:25:18 +00:00
|
|
|
}
|
1999-01-26 10:37:57 +00:00
|
|
|
if (lpSmallList)
|
|
|
|
{ *lpSmallList = ShellSmallIconList;
|
1998-11-15 13:25:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-04-11 11:50:41 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* PidlToSicIndex [INTERNAL]
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* sh [IN] IShellFolder
|
|
|
|
* pidl [IN]
|
|
|
|
* bBigIcon [IN]
|
2000-02-26 18:47:23 +00:00
|
|
|
* uFlags [IN] GIL_*
|
1999-04-11 11:50:41 +00:00
|
|
|
* pIndex [OUT] index within the SIC
|
|
|
|
*
|
|
|
|
*/
|
2000-02-26 18:47:23 +00:00
|
|
|
BOOL PidlToSicIndex (
|
|
|
|
IShellFolder * sh,
|
2003-09-02 01:01:06 +00:00
|
|
|
LPCITEMIDLIST pidl,
|
2000-02-26 18:47:23 +00:00
|
|
|
BOOL bBigIcon,
|
|
|
|
UINT uFlags,
|
|
|
|
UINT * pIndex)
|
2002-05-31 23:06:46 +00:00
|
|
|
{
|
2000-02-26 18:47:23 +00:00
|
|
|
IExtractIconA *ei;
|
1999-04-11 11:50:41 +00:00
|
|
|
char szIconFile[MAX_PATH]; /* file containing the icon */
|
|
|
|
INT iSourceIndex; /* index or resID(negated) in this file */
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
UINT dwFlags = 0;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2000-02-26 18:47:23 +00:00
|
|
|
TRACE("sf=%p pidl=%p %s\n", sh, pidl, bBigIcon?"Big":"Small");
|
1999-04-22 09:20:01 +00:00
|
|
|
|
1999-04-11 11:50:41 +00:00
|
|
|
if (SUCCEEDED (IShellFolder_GetUIObjectOf(sh, 0, 1, &pidl, &IID_IExtractIconA, 0, (void **)&ei)))
|
|
|
|
{
|
2000-02-26 18:47:23 +00:00
|
|
|
if (SUCCEEDED(IExtractIconA_GetIconLocation(ei, uFlags, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags)))
|
|
|
|
{
|
|
|
|
*pIndex = SIC_GetIconIndex(szIconFile, iSourceIndex);
|
1999-04-22 09:20:01 +00:00
|
|
|
ret = TRUE;
|
1999-04-11 11:50:41 +00:00
|
|
|
}
|
|
|
|
IExtractIconA_Release(ei);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (INVALID_INDEX == *pIndex) /* default icon when failed */
|
|
|
|
*pIndex = 1;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
1998-11-15 13:25:18 +00:00
|
|
|
|
|
|
|
/*************************************************************************
|
1999-03-13 17:10:36 +00:00
|
|
|
* SHMapPIDLToSystemImageListIndex [SHELL32.77]
|
1998-11-15 13:25:18 +00:00
|
|
|
*
|
|
|
|
* PARAMETERS
|
2002-05-31 23:06:46 +00:00
|
|
|
* sh [IN] pointer to an instance of IShellFolder
|
1999-04-11 11:50:41 +00:00
|
|
|
* pidl [IN]
|
|
|
|
* pIndex [OUT][OPTIONAL] SIC index for big icon
|
1998-11-15 13:25:18 +00:00
|
|
|
*
|
|
|
|
*/
|
2000-04-28 20:18:15 +00:00
|
|
|
int WINAPI SHMapPIDLToSystemImageListIndex(
|
|
|
|
LPSHELLFOLDER sh,
|
|
|
|
LPCITEMIDLIST pidl,
|
|
|
|
UINT * pIndex)
|
1999-04-11 11:50:41 +00:00
|
|
|
{
|
|
|
|
UINT Index;
|
1998-11-15 13:25:18 +00:00
|
|
|
|
1999-08-15 14:26:30 +00:00
|
|
|
TRACE("(SF=%p,pidl=%p,%p)\n",sh,pidl,pIndex);
|
1998-12-14 17:37:38 +00:00
|
|
|
pdump(pidl);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-04-11 11:50:41 +00:00
|
|
|
if (pIndex)
|
2000-02-26 18:47:23 +00:00
|
|
|
PidlToSicIndex ( sh, pidl, 1, 0, pIndex);
|
|
|
|
PidlToSicIndex ( sh, pidl, 0, 0, &Index);
|
1999-04-11 11:50:41 +00:00
|
|
|
return Index;
|
1998-11-15 13:25:18 +00:00
|
|
|
}
|
|
|
|
|
1999-01-03 12:33:08 +00:00
|
|
|
/*************************************************************************
|
1999-03-13 17:10:36 +00:00
|
|
|
* Shell_GetCachedImageIndex [SHELL32.72]
|
1999-01-03 12:33:08 +00:00
|
|
|
*
|
|
|
|
*/
|
2002-05-31 23:06:46 +00:00
|
|
|
INT WINAPI Shell_GetCachedImageIndexA(LPCSTR szPath, INT nIndex, BOOL bSimulateDoc)
|
1999-04-11 11:50:41 +00:00
|
|
|
{
|
1999-06-12 15:45:58 +00:00
|
|
|
WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_a(szPath), nIndex, bSimulateDoc);
|
1999-01-03 12:33:08 +00:00
|
|
|
return SIC_GetIconIndex(szPath, nIndex);
|
|
|
|
}
|
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
INT WINAPI Shell_GetCachedImageIndexW(LPCWSTR szPath, INT nIndex, BOOL bSimulateDoc)
|
1999-02-26 11:11:13 +00:00
|
|
|
{ INT ret;
|
1999-04-11 11:50:41 +00:00
|
|
|
LPSTR sTemp = HEAP_strdupWtoA (GetProcessHeap(),0,szPath);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_w(szPath), nIndex, bSimulateDoc);
|
1999-01-03 12:33:08 +00:00
|
|
|
|
|
|
|
ret = SIC_GetIconIndex(sTemp, nIndex);
|
|
|
|
HeapFree(GetProcessHeap(),0,sTemp);
|
1999-04-11 11:50:41 +00:00
|
|
|
return ret;
|
1999-01-03 12:33:08 +00:00
|
|
|
}
|
|
|
|
|
1999-04-11 11:50:41 +00:00
|
|
|
INT WINAPI Shell_GetCachedImageIndexAW(LPCVOID szPath, INT nIndex, BOOL bSimulateDoc)
|
2000-08-14 14:35:01 +00:00
|
|
|
{ if( SHELL_OsIsUnicode())
|
1999-04-11 11:50:41 +00:00
|
|
|
return Shell_GetCachedImageIndexW(szPath, nIndex, bSimulateDoc);
|
|
|
|
return Shell_GetCachedImageIndexA(szPath, nIndex, bSimulateDoc);
|
1999-01-03 12:33:08 +00:00
|
|
|
}
|
|
|
|
|
1998-11-15 13:25:18 +00:00
|
|
|
/*************************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* ExtractIconEx [SHELL32.@]
|
1999-03-13 17:10:36 +00:00
|
|
|
*/
|
2002-12-10 19:10:11 +00:00
|
|
|
UINT WINAPI ExtractIconExAW(LPCVOID lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons)
|
2000-08-14 14:35:01 +00:00
|
|
|
{ if (SHELL_OsIsUnicode())
|
1999-02-26 11:11:13 +00:00
|
|
|
return ExtractIconExW ( lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
|
|
|
|
return ExtractIconExA ( lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
|
1998-11-15 13:25:18 +00:00
|
|
|
}
|
2002-12-03 21:35:43 +00:00
|
|
|
|
1998-11-15 13:25:18 +00:00
|
|
|
/*************************************************************************
|
2002-12-03 21:35:43 +00:00
|
|
|
* ExtractIconExW [SHELL32.@]
|
|
|
|
* RETURNS:
|
2002-05-31 23:06:46 +00:00
|
|
|
* 0 no icon found
|
2002-12-10 19:10:11 +00:00
|
|
|
* -1 file is not valid
|
|
|
|
* or number of icons extracted
|
1999-03-13 17:10:36 +00:00
|
|
|
*/
|
2002-12-10 19:10:11 +00:00
|
|
|
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons)
|
2002-12-03 21:35:43 +00:00
|
|
|
{
|
2002-12-10 19:10:11 +00:00
|
|
|
TRACE("%s %i %p %p %i\n", debugstr_w(lpszFile), nIconIndex, phiconLarge, phiconSmall, nIcons);
|
|
|
|
|
|
|
|
return PrivateExtractIconExW(lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
|
1998-11-15 13:25:18 +00:00
|
|
|
}
|
2002-12-03 21:35:43 +00:00
|
|
|
|
1998-11-15 13:25:18 +00:00
|
|
|
/*************************************************************************
|
2002-12-03 21:35:43 +00:00
|
|
|
* ExtractIconExA [SHELL32.@]
|
1999-03-13 17:10:36 +00:00
|
|
|
*/
|
2002-12-10 19:10:11 +00:00
|
|
|
UINT WINAPI ExtractIconExA(LPCSTR lpszFile, INT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIcons)
|
2002-12-03 21:35:43 +00:00
|
|
|
{
|
2002-12-10 19:10:11 +00:00
|
|
|
UINT ret;
|
2002-12-03 21:35:43 +00:00
|
|
|
INT len = MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, NULL, 0);
|
|
|
|
LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2002-12-03 21:35:43 +00:00
|
|
|
TRACE("%s %i %p %p %i\n", lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
|
1998-11-15 13:25:18 +00:00
|
|
|
|
2002-12-03 21:35:43 +00:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, lpwstrFile, len);
|
|
|
|
ret = ExtractIconExW (lpwstrFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpwstrFile);
|
|
|
|
return ret;
|
1998-11-15 13:25:18 +00:00
|
|
|
}
|
2002-06-21 20:08:50 +00:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* ExtractAssociatedIconA (SHELL32.@)
|
|
|
|
*
|
|
|
|
* Return icon for given file (either from file itself or from associated
|
|
|
|
* executable) and patch parameters if needed.
|
|
|
|
*/
|
|
|
|
HICON WINAPI ExtractAssociatedIconA(HINSTANCE hInst, LPSTR lpIconPath, LPWORD lpiIcon)
|
2002-10-10 21:22:09 +00:00
|
|
|
{
|
|
|
|
HICON hIcon;
|
|
|
|
WORD wDummyIcon = 0;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if(lpiIcon == NULL)
|
|
|
|
lpiIcon = &wDummyIcon;
|
|
|
|
|
|
|
|
hIcon = ExtractIconA(hInst, lpIconPath, *lpiIcon);
|
|
|
|
|
|
|
|
if( hIcon < (HICON)2 )
|
|
|
|
{ if( hIcon == (HICON)1 ) /* no icons found in given file */
|
|
|
|
{ char tempPath[0x80];
|
2002-10-10 23:29:21 +00:00
|
|
|
HINSTANCE uRet = FindExecutableA(lpIconPath,NULL,tempPath);
|
2002-10-10 21:22:09 +00:00
|
|
|
|
2002-10-10 23:29:21 +00:00
|
|
|
if( uRet > (HINSTANCE)32 && tempPath[0] )
|
2002-10-10 21:22:09 +00:00
|
|
|
{ strcpy(lpIconPath,tempPath);
|
|
|
|
hIcon = ExtractIconA(hInst, lpIconPath, *lpiIcon);
|
|
|
|
if( hIcon > (HICON)2 )
|
|
|
|
return hIcon;
|
|
|
|
}
|
|
|
|
else hIcon = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( hIcon == (HICON)1 )
|
|
|
|
*lpiIcon = 2; /* MSDOS icon - we found .exe but no icons in it */
|
|
|
|
else
|
|
|
|
*lpiIcon = 6; /* generic icon - found nothing */
|
|
|
|
|
2002-11-21 23:56:42 +00:00
|
|
|
GetModuleFileNameA(hInst, lpIconPath, 0x80);
|
2002-10-10 21:22:09 +00:00
|
|
|
hIcon = LoadIconA( hInst, MAKEINTRESOURCEA(*lpiIcon));
|
|
|
|
}
|
|
|
|
return hIcon;
|
2002-06-21 20:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2002-11-30 02:22:24 +00:00
|
|
|
* ExtractAssociatedIconExW (SHELL32.@)
|
2002-06-21 20:08:50 +00:00
|
|
|
*
|
|
|
|
* Return icon for given file (either from file itself or from associated
|
|
|
|
* executable) and patch parameters if needed.
|
|
|
|
*/
|
2002-11-30 02:22:24 +00:00
|
|
|
HICON WINAPI ExtractAssociatedIconExW(HINSTANCE hInst, LPWSTR lpIconPath, LPWORD lpiIconIdx, LPWORD lpiIconId)
|
2002-06-21 20:08:50 +00:00
|
|
|
{
|
2002-11-30 02:22:24 +00:00
|
|
|
FIXME("%p %s %p %p): stub\n", hInst, debugstr_w(lpIconPath), lpiIconIdx, lpiIconId);
|
2002-06-21 20:08:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2002-11-30 02:22:24 +00:00
|
|
|
* ExtractAssociatedIconExA (SHELL32.@)
|
2002-06-21 20:08:50 +00:00
|
|
|
*
|
|
|
|
* Return icon for given file (either from file itself or from associated
|
|
|
|
* executable) and patch parameters if needed.
|
|
|
|
*/
|
2002-11-30 02:22:24 +00:00
|
|
|
HICON WINAPI ExtractAssociatedIconExA(HINSTANCE hInst, LPSTR lpIconPath, LPWORD lpiIconIdx, LPWORD lpiIconId)
|
2002-06-21 20:08:50 +00:00
|
|
|
{
|
2002-11-30 02:22:24 +00:00
|
|
|
HICON ret;
|
|
|
|
INT len = MultiByteToWideChar( CP_ACP, 0, lpIconPath, -1, NULL, 0 );
|
|
|
|
LPWSTR lpwstrFile = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
|
|
|
|
|
|
|
TRACE("%p %s %p %p)\n", hInst, lpIconPath, lpiIconIdx, lpiIconId);
|
|
|
|
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, lpIconPath, -1, lpwstrFile, len );
|
|
|
|
ret = ExtractAssociatedIconExW(hInst, lpwstrFile, lpiIconIdx, lpiIconId);
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpwstrFile);
|
|
|
|
return ret;
|
2002-06-21 20:08:50 +00:00
|
|
|
}
|
2002-12-07 23:49:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* SHDefExtractIconW [SHELL32.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI SHDefExtractIconW(LPCWSTR pszIconFile, int iIndex, UINT uFlags,
|
|
|
|
HICON* phiconLarge, HICON* phiconSmall, UINT nIconSize)
|
|
|
|
{
|
|
|
|
UINT ret;
|
|
|
|
HICON hIcons[2];
|
|
|
|
WARN("%s %d 0x%08x %p %p %d, semi-stub\n", debugstr_w(pszIconFile), iIndex, uFlags, phiconLarge, phiconSmall, nIconSize);
|
|
|
|
|
|
|
|
ret = PrivateExtractIconsW(pszIconFile, iIndex, nIconSize, nIconSize, hIcons, NULL, 2, LR_DEFAULTCOLOR);
|
|
|
|
/* FIXME: deal with uFlags parameter which contains GIL_ flags */
|
|
|
|
if (ret == 0xFFFFFFFF)
|
|
|
|
return E_FAIL;
|
|
|
|
if (ret > 0) {
|
|
|
|
*phiconLarge = hIcons[0];
|
|
|
|
*phiconSmall = hIcons[1];
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* SHDefExtractIconA [SHELL32.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI SHDefExtractIconA(LPCSTR pszIconFile, int iIndex, UINT uFlags,
|
|
|
|
HICON* phiconLarge, HICON* phiconSmall, UINT nIconSize)
|
|
|
|
{
|
|
|
|
HRESULT ret;
|
|
|
|
INT len = MultiByteToWideChar(CP_ACP, 0, pszIconFile, -1, NULL, 0);
|
|
|
|
LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
|
|
|
|
TRACE("%s %d 0x%08x %p %p %d\n", pszIconFile, iIndex, uFlags, phiconLarge, phiconSmall, nIconSize);
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pszIconFile, -1, lpwstrFile, len);
|
|
|
|
ret = SHDefExtractIconW(lpwstrFile, iIndex, uFlags, phiconLarge, phiconSmall, nIconSize);
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpwstrFile);
|
|
|
|
return ret;
|
|
|
|
}
|