2 * Copyright 1997 Marcus Meissner
3 * Copyright 1998 Juergen Schmied
11 #include "wine/obj_base.h"
12 #include "wine/obj_extracticon.h"
13 #include "wine/undocshell.h"
15 #include "debugtools.h"
19 #include "shell32_main.h"
21 DEFAULT_DEBUG_CHANNEL(shell)
24 /***********************************************************************
25 * IExtractIconA implementation
29 { ICOM_VFIELD(IExtractIconA);
31 ICOM_VTABLE(IPersistFile)* lpvtblPersistFile;
35 static struct ICOM_VTABLE(IExtractIconA) eivt;
36 static struct ICOM_VTABLE(IPersistFile) pfvt;
38 #define _IPersistFile_Offset ((int)(&(((IExtractIconAImpl*)0)->lpvtblPersistFile)))
39 #define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
41 /**************************************************************************
42 * IExtractIconA_Constructor
44 IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl)
46 IExtractIconAImpl* ei;
48 ei=(IExtractIconAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconAImpl));
50 ICOM_VTBL(ei) = &eivt;
51 ei->lpvtblPersistFile = &pfvt;
52 ei->pidl=ILClone(pidl);
58 return (IExtractIconA *)ei;
60 /**************************************************************************
61 * IExtractIconA_QueryInterface
63 static HRESULT WINAPI IExtractIconA_fnQueryInterface( IExtractIconA * iface, REFIID riid, LPVOID *ppvObj)
65 ICOM_THIS(IExtractIconAImpl,iface);
67 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
71 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
74 else if(IsEqualIID(riid, &IID_IPersistFile)) /*IExtractIcon*/
75 { *ppvObj = (IPersistFile*)&(This->lpvtblPersistFile);
77 else if(IsEqualIID(riid, &IID_IExtractIconA)) /*IExtractIcon*/
78 { *ppvObj = (IExtractIconA*)This;
82 { IExtractIconA_AddRef((IExtractIconA*) *ppvObj);
83 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
86 TRACE("-- Interface: E_NOINTERFACE\n");
90 /**************************************************************************
91 * IExtractIconA_AddRef
93 static ULONG WINAPI IExtractIconA_fnAddRef(IExtractIconA * iface)
95 ICOM_THIS(IExtractIconAImpl,iface);
97 TRACE("(%p)->(count=%lu)\n",This, This->ref );
101 return ++(This->ref);
103 /**************************************************************************
104 * IExtractIconA_Release
106 static ULONG WINAPI IExtractIconA_fnRelease(IExtractIconA * iface)
108 ICOM_THIS(IExtractIconAImpl,iface);
110 TRACE("(%p)->()\n",This);
115 { TRACE(" destroying IExtractIcon(%p)\n",This);
117 HeapFree(GetProcessHeap(),0,This);
122 /**************************************************************************
123 * IExtractIconA_GetIconLocation
125 * mapping filetype to icon
127 static HRESULT WINAPI IExtractIconA_fnGetIconLocation(
128 IExtractIconA * iface,
135 ICOM_THIS(IExtractIconAImpl,iface);
137 char sTemp[MAX_PATH];
140 LPITEMIDLIST pSimplePidl = ILFindLastID(This->pidl);
142 TRACE("(%p) (flags=%u %p %u %p %p)\n", This, uFlags, szIconFile, cchMax, piIndex, pwFlags);
147 if (_ILIsDesktop(pSimplePidl))
149 lstrcpynA(szIconFile, "shell32.dll", cchMax);
153 /* my computer and other shell extensions */
154 else if ( (riid = _ILGetGUIDPointer(pSimplePidl)) )
157 sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
158 riid->Data1, riid->Data2, riid->Data3,
159 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
160 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
162 if (HCR_GetDefaultIcon(xriid, sTemp, MAX_PATH, &dwNr))
164 lstrcpynA(szIconFile, sTemp, cchMax);
169 lstrcpynA(szIconFile, "shell32.dll", cchMax);
174 else if (_ILIsDrive (pSimplePidl))
176 if (HCR_GetDefaultIcon("Drive", sTemp, MAX_PATH, &dwNr))
178 lstrcpynA(szIconFile, sTemp, cchMax);
183 lstrcpynA(szIconFile, "shell32.dll", cchMax);
187 else if (_ILIsFolder (pSimplePidl))
189 if (HCR_GetDefaultIcon("Folder", sTemp, MAX_PATH, &dwNr))
191 lstrcpynA(szIconFile, sTemp, cchMax);
196 lstrcpynA(szIconFile, "shell32.dll", cchMax);
197 *piIndex = (uFlags & GIL_OPENICON)? 4 : 3;
200 else /* object is file */
202 if (_ILGetExtension (pSimplePidl, sTemp, MAX_PATH)
203 && HCR_MapTypeToValue(sTemp, sTemp, MAX_PATH, TRUE)
204 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
206 if (!strcmp("%1",sTemp)) /* icon is in the file */
208 SHGetPathFromIDListA(This->pidl, sTemp);
211 lstrcpynA(szIconFile, sTemp, cchMax);
214 else /* default icon */
216 lstrcpynA(szIconFile, "shell32.dll", cchMax);
221 TRACE("-- %s %x\n", szIconFile, *piIndex);
224 /**************************************************************************
225 * IExtractIconA_Extract
227 static HRESULT WINAPI IExtractIconA_fnExtract(IExtractIconA * iface, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
229 ICOM_THIS(IExtractIconAImpl,iface);
231 FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
234 *phiconLarge = pImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
237 *phiconSmall = pImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
242 static struct ICOM_VTABLE(IExtractIconA) eivt =
244 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
245 IExtractIconA_fnQueryInterface,
246 IExtractIconA_fnAddRef,
247 IExtractIconA_fnRelease,
248 IExtractIconA_fnGetIconLocation,
249 IExtractIconA_fnExtract
252 /************************************************************************
253 * IEIPersistFile_QueryInterface (IUnknown)
255 static HRESULT WINAPI IEIPersistFile_fnQueryInterface(
260 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
262 return IShellFolder_QueryInterface((IExtractIconA*)This, iid, ppvObj);
265 /************************************************************************
266 * IEIPersistFile_AddRef (IUnknown)
268 static ULONG WINAPI IEIPersistFile_fnAddRef(
271 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
273 return IExtractIconA_AddRef((IExtractIconA*)This);
276 /************************************************************************
277 * IEIPersistFile_Release (IUnknown)
279 static ULONG WINAPI IEIPersistFile_fnRelease(
282 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
284 return IExtractIconA_Release((IExtractIconA*)This);
287 /************************************************************************
288 * IEIPersistFile_GetClassID (IPersist)
290 static HRESULT WINAPI IEIPersistFile_fnGetClassID(
294 CLSID StdFolderID = { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
299 memcpy(lpClassId, &StdFolderID, sizeof(StdFolderID));
304 /************************************************************************
305 * IEIPersistFile_Load (IPersistFile)
307 static HRESULT WINAPI IEIPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
309 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
315 static struct ICOM_VTABLE(IPersistFile) pfvt =
317 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
318 IEIPersistFile_fnQueryInterface,
319 IEIPersistFile_fnAddRef,
320 IEIPersistFile_fnRelease,
321 IEIPersistFile_fnGetClassID,
322 (void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */,
323 IEIPersistFile_fnLoad,
324 (void *) 0xdeadbeef /* IEIPersistFile_fnSave */,
325 (void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
326 (void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */