Author: gadamopoulos
Date: Sun May 1 19:54:23 2016
New Revision: 71227
URL:
http://svn.reactos.org/svn/reactos?rev=71227&view=rev
Log:
[SHELL32]
- Remove IExtractIconA_Constructor and rename IExtractIconW_Constructor to
GenericExtractIcon_CreateInstance which will handle both A and W.
- Make GenericExtractIcon_CreateInstance accept a pointer to a IShellFolder and a simple
pidl.
- Avoid using SHGetPathFromIDListW. Use ILGetDisplayNameExW instead. May make loading
icons for folders and exe files slightly faster as it does fewer I/O and less
allocations.
Modified:
trunk/reactos/dll/win32/shell32/folders.cpp
trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp
trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp
trunk/reactos/dll/win32/shell32/wine/shell32_main.h
Modified: trunk/reactos/dll/win32/shell32/folders.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders.…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders.cpp [iso-8859-1] Sun May 1 19:54:23 2016
@@ -24,7 +24,7 @@
DWORD NumIconOverlayHandlers = 0;
IShellIconOverlayIdentifier ** Handlers = NULL;
-static HRESULT getIconLocationForFolder(LPCITEMIDLIST pidl, UINT uFlags,
+static HRESULT getIconLocationForFolder(IShellFolder * psf, LPCITEMIDLIST pidl, UINT
uFlags,
LPWSTR szIconFile, UINT cchMax, int *piIndex,
UINT *pwFlags)
{
static const WCHAR shellClassInfo[] = { '.', 'S', 'h',
'e', 'l', 'l', 'C', 'l', 'a', 's',
's', 'I', 'n', 'f', 'o', 0 };
@@ -39,7 +39,7 @@
{
WCHAR wszFolderPath[MAX_PATH];
- if (!SHGetPathFromIDListW(pidl, wszFolderPath))
+ if (!ILGetDisplayNameExW(psf, pidl, wszFolderPath, 0))
return FALSE;
PathAppendW(wszFolderPath, wszDesktopIni);
@@ -192,28 +192,20 @@
return FALSE;
}
-/**************************************************************************
-* IExtractIconW_Constructor
-*/
-IExtractIconW* IExtractIconW_Constructor(LPCITEMIDLIST pidl)
+HRESULT GenericExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID
iid, LPVOID * ppvOut)
{
CComPtr<IDefaultExtractIconInit> initIcon;
- CComPtr<IExtractIconW> extractIcon;
GUID const * riid;
int icon_idx;
UINT flags;
CHAR sTemp[MAX_PATH];
WCHAR wTemp[MAX_PATH];
- LPITEMIDLIST pSimplePidl = ILFindLastID(pidl);
+ LPCITEMIDLIST pSimplePidl = pidl;
HRESULT hr;
hr = SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit,&initIcon));
if (FAILED(hr))
- return NULL;
-
- hr = initIcon->QueryInterface(IID_PPV_ARG(IExtractIconW,&extractIcon));
- if (FAILED(hr))
- return NULL;
+ return hr;
if (_ILIsDesktop(pSimplePidl))
{
@@ -321,7 +313,7 @@
else if (_ILIsFolder (pSimplePidl))
{
- if (SUCCEEDED(getIconLocationForFolder(
+ if (SUCCEEDED(getIconLocationForFolder(psf,
pidl, 0, wTemp, MAX_PATH,
&icon_idx,
&flags)))
@@ -332,21 +324,21 @@
// the following line removed.
initIcon->SetShortcutIcon(wTemp, icon_idx);
}
- if (SUCCEEDED(getIconLocationForFolder(
+ if (SUCCEEDED(getIconLocationForFolder(psf,
pidl, GIL_DEFAULTICON, wTemp, MAX_PATH,
&icon_idx,
&flags)))
{
initIcon->SetDefaultIcon(wTemp, icon_idx);
}
- // if (SUCCEEDED(getIconLocationForFolder(
+ // if (SUCCEEDED(getIconLocationForFolder(psf,
// pidl, GIL_FORSHORTCUT, wTemp, MAX_PATH,
// &icon_idx,
// &flags)))
// {
// initIcon->SetShortcutIcon(wTemp, icon_idx);
// }
- if (SUCCEEDED(getIconLocationForFolder(
+ if (SUCCEEDED(getIconLocationForFolder(psf,
pidl, GIL_OPENICON, wTemp, MAX_PATH,
&icon_idx,
&flags)))
@@ -365,7 +357,7 @@
{
if (!lstrcmpA("%1", sTemp)) /* icon is in the file */
{
- SHGetPathFromIDListW(pidl, wTemp);
+ ILGetDisplayNameExW(psf, pidl, wTemp, 0);
icon_idx = 0;
}
else
@@ -383,7 +375,7 @@
if (SUCCEEDED(SHGetDesktopFolder(&dsf)))
{
- HRESULT hr = dsf->GetUIObjectOf(NULL, 1, (LPCITEMIDLIST*)
&pidl, IID_NULL_PPV_ARG(IShellLinkW, &psl));
+ HRESULT hr = dsf->GetUIObjectOf(NULL, 1, &pidl,
IID_NULL_PPV_ARG(IShellLinkW, &psl));
if (SUCCEEDED(hr))
{
@@ -404,24 +396,5 @@
initIcon->SetNormalIcon(wTemp, icon_idx);
}
- return extractIcon.Detach();
+ return initIcon->QueryInterface(iid, ppvOut);
}
-
-/**************************************************************************
-* IExtractIconA_Constructor
-*/
-IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl)
-{
- CComPtr<IExtractIconW> extractIconW;
- CComPtr<IExtractIconA> extractIconA;
- HRESULT hr;
-
- extractIconW = IExtractIconW_Constructor(pidl);
- if (!extractIconW)
- return NULL;
-
- hr = extractIconW->QueryInterface(IID_PPV_ARG(IExtractIconA, &extractIconA));
- if (FAILED(hr))
- return NULL;
- return extractIconA.Detach();
-}
Modified: trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp [iso-8859-1]
(original)
+++ trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp [iso-8859-1] Sun May
1 19:54:23 2016
@@ -125,19 +125,12 @@
return NULL;
}
-HRESULT CCPLExtractIcon_CreateInstance(LPCITEMIDLIST pidlRoot, LPCITEMIDLIST pidl, REFIID
riid, LPVOID * ppvOut)
+HRESULT CCPLExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID
riid, LPVOID * ppvOut)
{
PIDLCPanelStruct *pData = _ILGetCPanelPointer(pidl);
if (!pData)
{
- LPITEMIDLIST pidlComplete = ILCombine(pidlRoot, pidl);
- if (!pidlComplete)
- return E_OUTOFMEMORY;
-
- *ppvOut = IExtractIconW_Constructor(pidlComplete);
-
- SHFree(pidlComplete);
- return *ppvOut ? S_OK : E_FAIL;
+ return GenericExtractIcon_CreateInstance(psf, pidl, riid, ppvOut);
}
CComPtr<IDefaultExtractIconInit> initIcon;
@@ -508,7 +501,7 @@
} else if (IsEqualIID(riid, IID_IDataObject) && (cidl >= 1)) {
hr = IDataObject_Constructor(hwndOwner, pidlRoot, apidl, cidl, (IDataObject
**)&pObj);
} else if ((IsEqualIID(riid, IID_IExtractIconA) || IsEqualIID(riid,
IID_IExtractIconW)) && (cidl == 1)) {
- hr = CCPLExtractIcon_CreateInstance(pidlRoot, apidl[0], riid, &pObj);
+ hr = CCPLExtractIcon_CreateInstance(this, apidl[0], riid, &pObj);
} else if ((IsEqualIID(riid, IID_IShellLinkW) || IsEqualIID(riid,
IID_IShellLinkA))
&& (cidl == 1)) {
Modified: trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp [iso-8859-1] Sun May 1
19:54:23 2016
@@ -590,7 +590,7 @@
LPVOID *ppvOut)
{
LPITEMIDLIST pidl;
- IUnknown *pObj = NULL;
+ LPVOID pObj = NULL;
HRESULT hr = E_INVALIDARG;
TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
@@ -609,19 +609,9 @@
{
hr = IDataObject_Constructor( hwndOwner, pidlRoot, apidl, cidl, (IDataObject
**)&pObj);
}
- else if (IsEqualIID (riid, IID_IExtractIconA) && (cidl == 1))
- {
- pidl = ILCombine (pidlRoot, apidl[0]);
- pObj = IExtractIconA_Constructor (pidl);
- SHFree (pidl);
- hr = S_OK;
- }
- else if (IsEqualIID (riid, IID_IExtractIconW) && (cidl == 1))
- {
- pidl = ILCombine (pidlRoot, apidl[0]);
- pObj = IExtractIconW_Constructor (pidl);
- SHFree (pidl);
- hr = S_OK;
+ else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid,
IID_IExtractIconW)) && (cidl == 1))
+ {
+ hr = GenericExtractIcon_CreateInstance(this, apidl[0], riid, &pObj);
}
else if (IsEqualIID (riid, IID_IDropTarget))
{
Modified: trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp [iso-8859-1] Sun May 1
19:54:23 2016
@@ -436,7 +436,7 @@
REFIID riid, UINT *prgfInOut, LPVOID *ppvOut)
{
LPITEMIDLIST pidl;
- IUnknown *pObj = NULL;
+ LPVOID pObj = NULL;
HRESULT hr = E_INVALIDARG;
TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", this,
@@ -456,19 +456,9 @@
hr = IDataObject_Constructor (hwndOwner,
pidlRoot, apidl, cidl, (IDataObject **)&pObj);
}
- else if (IsEqualIID (riid, IID_IExtractIconA) && (cidl == 1))
- {
- pidl = ILCombine (pidlRoot, apidl[0]);
- pObj = IExtractIconA_Constructor (pidl);
- SHFree (pidl);
- hr = S_OK;
- }
- else if (IsEqualIID (riid, IID_IExtractIconW) && (cidl == 1))
- {
- pidl = ILCombine (pidlRoot, apidl[0]);
- pObj = IExtractIconW_Constructor (pidl);
- SHFree (pidl);
- hr = S_OK;
+ else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid,
IID_IExtractIconW)) && (cidl == 1))
+ {
+ hr = GenericExtractIcon_CreateInstance(this, apidl[0], riid, &pObj);
}
else if (IsEqualIID (riid, IID_IDropTarget) && (cidl >= 1))
{
Modified: trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp [iso-8859-1] Sun May 1 19:54:23
2016
@@ -488,7 +488,7 @@
LPVOID * ppvOut)
{
LPITEMIDLIST pidl;
- IUnknown *pObj = NULL;
+ LPVOID pObj = NULL;
HRESULT hr = E_INVALIDARG;
TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
@@ -515,19 +515,9 @@
hr = IDataObject_Constructor (hwndOwner, pidlRoot,
(LPCITEMIDLIST*)&pidlRoot, 1, (IDataObject **)&pObj);
}
}
- else if (IsEqualIID (riid, IID_IExtractIconA) && (cidl == 1))
- {
- pidl = ILCombine (pidlRoot, apidl[0]);
- pObj = IExtractIconA_Constructor (pidl);
- SHFree (pidl);
- hr = S_OK;
- }
- else if (IsEqualIID (riid, IID_IExtractIconW) && (cidl == 1))
- {
- pidl = ILCombine (pidlRoot, apidl[0]);
- pObj = IExtractIconW_Constructor (pidl);
- SHFree (pidl);
- hr = S_OK;
+ else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid,
IID_IExtractIconW)) && (cidl == 1))
+ {
+ hr = GenericExtractIcon_CreateInstance(this, apidl[0], riid, &pObj);
}
else if (IsEqualIID (riid, IID_IDropTarget))
{
Modified: trunk/reactos/dll/win32/shell32/wine/shell32_main.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/wine/she…
==============================================================================
--- trunk/reactos/dll/win32/shell32/wine/shell32_main.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/wine/shell32_main.h [iso-8859-1] Sun May 1 19:54:23
2016
@@ -79,8 +79,7 @@
HRESULT WINAPI CPanel_ExtractIconA(LPITEMIDLIST pidl, LPCSTR pszFile, UINT nIconIndex,
HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) DECLSPEC_HIDDEN;
HRESULT WINAPI CPanel_ExtractIconW(LPITEMIDLIST pidl, LPCWSTR pszFile, UINT nIconIndex,
HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) DECLSPEC_HIDDEN;
-LPEXTRACTICONA IExtractIconA_Constructor(LPCITEMIDLIST) DECLSPEC_HIDDEN;
-LPEXTRACTICONW IExtractIconW_Constructor(LPCITEMIDLIST) DECLSPEC_HIDDEN;
+HRESULT GenericExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID
iid, LPVOID * ppvOut);
/* initialisation for FORMATETC */
#define InitFormatEtc(fe, cf, med) \