2 * Copyright 1997 Marcus Meissner
3 * Copyright 1998 Juergen Schmied
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "wine/obj_base.h"
26 #include "wine/obj_extracticon.h"
27 #include "undocshell.h"
30 #include "wine/debug.h"
34 #include "shell32_main.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(shell);
39 /***********************************************************************
40 * IExtractIconA implementation
44 { ICOM_VFIELD(IExtractIconA);
46 ICOM_VTABLE(IPersistFile)* lpvtblPersistFile;
50 static struct ICOM_VTABLE(IExtractIconA) eivt;
51 static struct ICOM_VTABLE(IPersistFile) pfvt;
53 #define _IPersistFile_Offset ((int)(&(((IExtractIconAImpl*)0)->lpvtblPersistFile)))
54 #define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
56 /**************************************************************************
57 * IExtractIconA_Constructor
59 IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl)
61 IExtractIconAImpl* ei;
63 ei=(IExtractIconAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconAImpl));
65 ICOM_VTBL(ei) = &eivt;
66 ei->lpvtblPersistFile = &pfvt;
67 ei->pidl=ILClone(pidl);
73 return (IExtractIconA *)ei;
75 /**************************************************************************
76 * IExtractIconA_QueryInterface
78 static HRESULT WINAPI IExtractIconA_fnQueryInterface( IExtractIconA * iface, REFIID riid, LPVOID *ppvObj)
80 ICOM_THIS(IExtractIconAImpl,iface);
82 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
86 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
89 else if(IsEqualIID(riid, &IID_IPersistFile)) /*IExtractIcon*/
90 { *ppvObj = (IPersistFile*)&(This->lpvtblPersistFile);
92 else if(IsEqualIID(riid, &IID_IExtractIconA)) /*IExtractIcon*/
93 { *ppvObj = (IExtractIconA*)This;
97 { IExtractIconA_AddRef((IExtractIconA*) *ppvObj);
98 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
101 TRACE("-- Interface: E_NOINTERFACE\n");
102 return E_NOINTERFACE;
105 /**************************************************************************
106 * IExtractIconA_AddRef
108 static ULONG WINAPI IExtractIconA_fnAddRef(IExtractIconA * iface)
110 ICOM_THIS(IExtractIconAImpl,iface);
112 TRACE("(%p)->(count=%lu)\n",This, This->ref );
116 return ++(This->ref);
118 /**************************************************************************
119 * IExtractIconA_Release
121 static ULONG WINAPI IExtractIconA_fnRelease(IExtractIconA * iface)
123 ICOM_THIS(IExtractIconAImpl,iface);
125 TRACE("(%p)->()\n",This);
130 { TRACE(" destroying IExtractIcon(%p)\n",This);
132 HeapFree(GetProcessHeap(),0,This);
137 /**************************************************************************
138 * IExtractIconA_GetIconLocation
140 * mapping filetype to icon
142 static HRESULT WINAPI IExtractIconA_fnGetIconLocation(
143 IExtractIconA * iface,
150 ICOM_THIS(IExtractIconAImpl,iface);
152 char sTemp[MAX_PATH];
155 LPITEMIDLIST pSimplePidl = ILFindLastID(This->pidl);
157 TRACE("(%p) (flags=%u %p %u %p %p)\n", This, uFlags, szIconFile, cchMax, piIndex, pwFlags);
162 if (_ILIsDesktop(pSimplePidl))
164 lstrcpynA(szIconFile, "shell32.dll", cchMax);
168 /* my computer and other shell extensions */
169 else if ( (riid = _ILGetGUIDPointer(pSimplePidl)) )
172 sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
173 riid->Data1, riid->Data2, riid->Data3,
174 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
175 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
177 if (HCR_GetDefaultIcon(xriid, sTemp, MAX_PATH, &dwNr))
179 lstrcpynA(szIconFile, sTemp, cchMax);
184 lstrcpynA(szIconFile, "shell32.dll", cchMax);
189 else if (_ILIsDrive (pSimplePidl))
191 if (HCR_GetDefaultIcon("Drive", sTemp, MAX_PATH, &dwNr))
193 lstrcpynA(szIconFile, sTemp, cchMax);
198 lstrcpynA(szIconFile, "shell32.dll", cchMax);
202 else if (_ILIsFolder (pSimplePidl))
204 if (HCR_GetDefaultIcon("Folder", sTemp, MAX_PATH, &dwNr))
206 lstrcpynA(szIconFile, sTemp, cchMax);
211 lstrcpynA(szIconFile, "shell32.dll", cchMax);
212 *piIndex = (uFlags & GIL_OPENICON)? 4 : 3;
215 else /* object is file */
217 if (_ILGetExtension (pSimplePidl, sTemp, MAX_PATH)
218 && HCR_MapTypeToValue(sTemp, sTemp, MAX_PATH, TRUE)
219 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
221 if (!strcmp("%1",sTemp)) /* icon is in the file */
223 SHGetPathFromIDListA(This->pidl, sTemp);
226 lstrcpynA(szIconFile, sTemp, cchMax);
229 else /* default icon */
231 lstrcpynA(szIconFile, "shell32.dll", cchMax);
236 TRACE("-- %s %x\n", szIconFile, *piIndex);
239 /**************************************************************************
240 * IExtractIconA_Extract
242 static HRESULT WINAPI IExtractIconA_fnExtract(IExtractIconA * iface, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
244 ICOM_THIS(IExtractIconAImpl,iface);
246 FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
249 *phiconLarge = ImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
252 *phiconSmall = ImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
257 static struct ICOM_VTABLE(IExtractIconA) eivt =
259 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
260 IExtractIconA_fnQueryInterface,
261 IExtractIconA_fnAddRef,
262 IExtractIconA_fnRelease,
263 IExtractIconA_fnGetIconLocation,
264 IExtractIconA_fnExtract
267 /************************************************************************
268 * IEIPersistFile_QueryInterface (IUnknown)
270 static HRESULT WINAPI IEIPersistFile_fnQueryInterface(
275 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
277 return IShellFolder_QueryInterface((IExtractIconA*)This, iid, ppvObj);
280 /************************************************************************
281 * IEIPersistFile_AddRef (IUnknown)
283 static ULONG WINAPI IEIPersistFile_fnAddRef(
286 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
288 return IExtractIconA_AddRef((IExtractIconA*)This);
291 /************************************************************************
292 * IEIPersistFile_Release (IUnknown)
294 static ULONG WINAPI IEIPersistFile_fnRelease(
297 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
299 return IExtractIconA_Release((IExtractIconA*)This);
302 /************************************************************************
303 * IEIPersistFile_GetClassID (IPersist)
305 static HRESULT WINAPI IEIPersistFile_fnGetClassID(
309 CLSID StdFolderID = { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
314 memcpy(lpClassId, &StdFolderID, sizeof(StdFolderID));
319 /************************************************************************
320 * IEIPersistFile_Load (IPersistFile)
322 static HRESULT WINAPI IEIPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
324 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
330 static struct ICOM_VTABLE(IPersistFile) pfvt =
332 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
333 IEIPersistFile_fnQueryInterface,
334 IEIPersistFile_fnAddRef,
335 IEIPersistFile_fnRelease,
336 IEIPersistFile_fnGetClassID,
337 (void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */,
338 IEIPersistFile_fnLoad,
339 (void *) 0xdeadbeef /* IEIPersistFile_fnSave */,
340 (void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
341 (void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */