Author: gadamopoulos
Date: Fri Jul 29 06:21:11 2016
New Revision: 72041
URL:
http://svn.reactos.org/svn/reactos?rev=72041&view=rev
Log:
[SHELLL32]
- Split GenericExtractIcon_CreateInstance into CGuidItemExtractIcon_CreateInstance,
CFSExtractIcon_CreateInstance and CDrivesExtractIcon_CreateInstance.
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] Fri Jul 29 06:21:11 2016
@@ -192,126 +192,102 @@
return FALSE;
}
-HRESULT GenericExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID
iid, LPVOID * ppvOut)
+HRESULT CGuidItemExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl,
REFIID iid, LPVOID * ppvOut)
{
CComPtr<IDefaultExtractIconInit> initIcon;
+ HRESULT hr;
GUID const * riid;
+ int icon_idx;
+ WCHAR wTemp[MAX_PATH];
+
+ hr = SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit,&initIcon));
+ if (FAILED(hr))
+ return hr;
+
+ if (_ILIsDesktop(pidl))
+ {
+ initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_DESKTOP);
+ return initIcon->QueryInterface(iid, ppvOut);
+ }
+
+ riid = _ILGetGUIDPointer(pidl);
+ if (!riid)
+ return E_FAIL;
+
+ /* my computer and other shell extensions */
+ static const WCHAR fmt[] = { 'C', 'L', 'S', 'I',
'D', '\\',
+ '{', '%', '0', '8',
'l', 'x', '-', '%', '0', '4', 'x',
'-', '%', '0', '4', 'x', '-',
+ '%', '0', '2', 'x',
'%', '0', '2', 'x', '-', '%', '0',
'2', 'x', '%', '0', '2', 'x',
+ '%', '0', '2', 'x',
'%', '0', '2', 'x', '%', '0', '2',
'x', '%', '0', '2', 'x', '}', 0
+ };
+ WCHAR xriid[50];
+
+ swprintf(xriid, fmt,
+ riid->Data1, riid->Data2, riid->Data3,
+ riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
+ riid->Data4[4], riid->Data4[5], riid->Data4[6],
riid->Data4[7]);
+
+ const WCHAR* iconname = NULL;
+ if (_ILIsBitBucket(pidl))
+ {
+ static const WCHAR szFull[] =
{'F','u','l','l',0};
+ static const WCHAR szEmpty[] =
{'E','m','p','t','y',0};
+ CComPtr<IEnumIDList> EnumIDList;
+ CoInitialize(NULL);
+
+ CComPtr<IShellFolder2> psfRecycleBin;
+ CComPtr<IShellFolder> psfDesktop;
+ hr = SHGetDesktopFolder(&psfDesktop);
+
+ if (SUCCEEDED(hr))
+ hr = psfDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder2,
&psfRecycleBin));
+ if (SUCCEEDED(hr))
+ hr = psfRecycleBin->EnumObjects(NULL, SHCONTF_FOLDERS |
SHCONTF_NONFOLDERS, &EnumIDList);
+
+ ULONG itemcount;
+ LPITEMIDLIST pidl = NULL;
+ if (SUCCEEDED(hr) && (hr = EnumIDList->Next(1, &pidl,
&itemcount)) == S_OK)
+ {
+ CoTaskMemFree(pidl);
+ iconname = szFull;
+ } else {
+ iconname = szEmpty;
+ }
+ }
+
+ if (HCR_GetIconW(xriid, wTemp, iconname, MAX_PATH, &icon_idx))
+ {
+ initIcon->SetNormalIcon(wTemp, icon_idx);
+ }
+ else
+ {
+ if (IsEqualGUID(*riid, CLSID_MyComputer))
+ initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_COMPUTER);
+ else if (IsEqualGUID(*riid, CLSID_MyDocuments))
+ initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_DOCUMENTS);
+ else if (IsEqualGUID(*riid, CLSID_NetworkPlaces))
+ initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_NETWORK_PLACES);
+ else
+ initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_FOLDER);
+ }
+
+ return initIcon->QueryInterface(iid, ppvOut);
+}
+
+HRESULT CFSExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID iid,
LPVOID * ppvOut)
+{
+ CComPtr<IDefaultExtractIconInit> initIcon;
+ HRESULT hr;
int icon_idx;
UINT flags;
CHAR sTemp[MAX_PATH];
WCHAR wTemp[MAX_PATH];
- LPCITEMIDLIST pSimplePidl = pidl;
- HRESULT hr;
hr = SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit,&initIcon));
if (FAILED(hr))
return hr;
- if (_ILIsDesktop(pSimplePidl))
- {
- initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_DESKTOP);
- }
- else if ((riid = _ILGetGUIDPointer(pSimplePidl)))
- {
- /* my computer and other shell extensions */
- static const WCHAR fmt[] = { 'C', 'L', 'S', 'I',
'D', '\\',
- '{', '%', '0', '8',
'l', 'x', '-', '%', '0', '4', 'x',
'-', '%', '0', '4', 'x', '-',
- '%', '0', '2', 'x',
'%', '0', '2', 'x', '-', '%', '0',
'2', 'x', '%', '0', '2', 'x',
- '%', '0', '2', 'x',
'%', '0', '2', 'x', '%', '0', '2',
'x', '%', '0', '2', 'x', '}', 0
- };
- WCHAR xriid[50];
-
- swprintf(xriid, fmt,
- riid->Data1, riid->Data2, riid->Data3,
- riid->Data4[0], riid->Data4[1], riid->Data4[2],
riid->Data4[3],
- riid->Data4[4], riid->Data4[5], riid->Data4[6],
riid->Data4[7]);
-
- const WCHAR* iconname = NULL;
- if (_ILIsBitBucket(pSimplePidl))
- {
- static const WCHAR szFull[] =
{'F','u','l','l',0};
- static const WCHAR szEmpty[] =
{'E','m','p','t','y',0};
- CComPtr<IEnumIDList> EnumIDList;
- CoInitialize(NULL);
-
- CComPtr<IShellFolder2> psfRecycleBin;
- CComPtr<IShellFolder> psfDesktop;
- hr = SHGetDesktopFolder(&psfDesktop);
-
- if (SUCCEEDED(hr))
- hr = psfDesktop->BindToObject(pSimplePidl, NULL,
IID_PPV_ARG(IShellFolder2, &psfRecycleBin));
- if (SUCCEEDED(hr))
- hr = psfRecycleBin->EnumObjects(NULL, SHCONTF_FOLDERS |
SHCONTF_NONFOLDERS, &EnumIDList);
-
- ULONG itemcount;
- LPITEMIDLIST pidl = NULL;
- if (SUCCEEDED(hr) && (hr = EnumIDList->Next(1, &pidl,
&itemcount)) == S_OK)
- {
- CoTaskMemFree(pidl);
- iconname = szFull;
- } else {
- iconname = szEmpty;
- }
- }
-
- if (HCR_GetIconW(xriid, wTemp, iconname, MAX_PATH, &icon_idx))
- {
- initIcon->SetNormalIcon(wTemp, icon_idx);
- }
- else
- {
- if (IsEqualGUID(*riid, CLSID_MyComputer))
- initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_COMPUTER);
- else if (IsEqualGUID(*riid, CLSID_MyDocuments))
- initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_DOCUMENTS);
- else if (IsEqualGUID(*riid, CLSID_NetworkPlaces))
- initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_NETWORK_PLACES);
- else
- initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_FOLDER);
- }
- }
-
- else if (_ILIsDrive (pSimplePidl))
- {
- static const WCHAR drive[] = { 'D', 'r', 'i',
'v', 'e', 0 };
- int icon_idx = -1;
-
- if (_ILGetDrive(pSimplePidl, sTemp, MAX_PATH))
- {
- switch(GetDriveTypeA(sTemp))
- {
- case DRIVE_REMOVABLE:
- icon_idx = IDI_SHELL_3_14_FLOPPY;
- break;
- case DRIVE_CDROM:
- icon_idx = IDI_SHELL_CDROM;
- break;
- case DRIVE_REMOTE:
- icon_idx = IDI_SHELL_NETDRIVE;
- break;
- case DRIVE_RAMDISK:
- icon_idx = IDI_SHELL_RAMDISK;
- break;
- case DRIVE_NO_ROOT_DIR:
- icon_idx = IDI_SHELL_CDROM;
- break;
- }
- }
-
- if (icon_idx != -1)
- {
- initIcon->SetNormalIcon(swShell32Name, -icon_idx);
- }
- else
- {
- if (HCR_GetIconW(drive, wTemp, NULL, MAX_PATH, &icon_idx))
- initIcon->SetNormalIcon(wTemp, icon_idx);
- else
- initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_DRIVE);
- }
- }
-
- else if (_ILIsFolder (pSimplePidl))
+ if (_ILIsFolder (pidl))
{
if (SUCCEEDED(getIconLocationForFolder(psf,
pidl, 0, wTemp, MAX_PATH,
@@ -350,7 +326,7 @@
{
BOOL found = FALSE;
- if (_ILGetExtension(pSimplePidl, sTemp, MAX_PATH))
+ if (_ILGetExtension(pidl, sTemp, MAX_PATH))
{
if (HCR_MapTypeToValueA(sTemp, sTemp, MAX_PATH, TRUE)
&& HCR_GetIconA(sTemp, sTemp, NULL, MAX_PATH,
&icon_idx))
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] Fri Jul
29 06:21:11 2016
@@ -130,7 +130,7 @@
PIDLCPanelStruct *pData = _ILGetCPanelPointer(pidl);
if (!pData)
{
- return GenericExtractIcon_CreateInstance(psf, pidl, riid, ppvOut);
+ return CGuidItemExtractIcon_CreateInstance(psf, pidl, riid, ppvOut);
}
CComPtr<IDefaultExtractIconInit> initIcon;
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] Fri Jul 29
06:21:11 2016
@@ -642,7 +642,7 @@
}
else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid,
IID_IExtractIconW)) && (cidl == 1))
{
- hr = GenericExtractIcon_CreateInstance(this, apidl[0], riid, &pObj);
+ hr = CGuidItemExtractIcon_CreateInstance(this, apidl[0], riid, &pObj);
}
else
hr = E_NOINTERFACE;
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] Fri Jul 29
06:21:11 2016
@@ -39,6 +39,58 @@
* IShellFolder implementation
*/
+HRESULT CDrivesExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID
riid, LPVOID * ppvOut)
+{
+ if (!_ILIsDrive(pidl))
+ {
+ return CGuidItemExtractIcon_CreateInstance(psf, pidl, riid, ppvOut);
+ }
+
+ CComPtr<IDefaultExtractIconInit> initIcon;
+ HRESULT hr = SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit,
&initIcon));
+ if (FAILED(hr))
+ return NULL;
+
+ CHAR* pszDrive = _ILGetDataPointer(pidl)->u.drive.szDriveName;
+ WCHAR wTemp[MAX_PATH];
+ int icon_idx = -1;
+
+ if (pszDrive)
+ {
+ switch(GetDriveTypeA(pszDrive))
+ {
+ case DRIVE_REMOVABLE:
+ icon_idx = IDI_SHELL_3_14_FLOPPY;
+ break;
+ case DRIVE_CDROM:
+ icon_idx = IDI_SHELL_CDROM;
+ break;
+ case DRIVE_REMOTE:
+ icon_idx = IDI_SHELL_NETDRIVE;
+ break;
+ case DRIVE_RAMDISK:
+ icon_idx = IDI_SHELL_RAMDISK;
+ break;
+ case DRIVE_NO_ROOT_DIR:
+ icon_idx = IDI_SHELL_CDROM;
+ break;
+ }
+ }
+
+ if (icon_idx != -1)
+ {
+ initIcon->SetNormalIcon(swShell32Name, -icon_idx);
+ }
+ else
+ {
+ if (HCR_GetIconW(L"Drive", wTemp, NULL, MAX_PATH, &icon_idx))
+ initIcon->SetNormalIcon(wTemp, icon_idx);
+ else
+ initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_DRIVE);
+ }
+
+ return initIcon->QueryInterface(riid, ppvOut);
+}
class CDrivesFolderEnum :
public CEnumIDListBase
{
@@ -457,7 +509,7 @@
}
else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid,
IID_IExtractIconW)) && (cidl == 1))
{
- hr = GenericExtractIcon_CreateInstance(this, apidl[0], riid, &pObj);
+ hr = CDrivesExtractIcon_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] Fri Jul 29 06:21:11
2016
@@ -516,7 +516,7 @@
}
else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid,
IID_IExtractIconW)) && (cidl == 1))
{
- hr = GenericExtractIcon_CreateInstance(this, apidl[0], riid, &pObj);
+ hr = CFSExtractIcon_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] Fri Jul 29 06:21:11
2016
@@ -80,7 +80,8 @@
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;
-HRESULT GenericExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID
iid, LPVOID * ppvOut);
+HRESULT CGuidItemExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl,
REFIID iid, LPVOID * ppvOut);
+HRESULT CFSExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID iid,
LPVOID * ppvOut);
/* initialisation for FORMATETC */
#define InitFormatEtc(fe, cf, med) \