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"
16 #include "debugtools.h"
20 #include "shell32_main.h"
22 DEFAULT_DEBUG_CHANNEL(shell)
25 /***********************************************************************
26 * IExtractIconA implementation
30 { ICOM_VFIELD(IExtractIconA);
32 ICOM_VTABLE(IPersistFile)* lpvtblPersistFile;
36 static struct ICOM_VTABLE(IExtractIconA) eivt;
37 static struct ICOM_VTABLE(IPersistFile) pfvt;
39 #define _IPersistFile_Offset ((int)(&(((IExtractIconAImpl*)0)->lpvtblPersistFile)))
40 #define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
42 /**************************************************************************
43 * IExtractIconA_Constructor
45 IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl)
47 IExtractIconAImpl* ei;
49 ei=(IExtractIconAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconAImpl));
51 ICOM_VTBL(ei) = &eivt;
52 ei->lpvtblPersistFile = &pfvt;
53 ei->pidl=ILClone(pidl);
59 return (IExtractIconA *)ei;
61 /**************************************************************************
62 * IExtractIconA_QueryInterface
64 static HRESULT WINAPI IExtractIconA_fnQueryInterface( IExtractIconA * iface, REFIID riid, LPVOID *ppvObj)
66 ICOM_THIS(IExtractIconAImpl,iface);
68 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
72 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
75 else if(IsEqualIID(riid, &IID_IPersistFile)) /*IExtractIcon*/
76 { *ppvObj = (IPersistFile*)&(This->lpvtblPersistFile);
78 else if(IsEqualIID(riid, &IID_IExtractIconA)) /*IExtractIcon*/
79 { *ppvObj = (IExtractIconA*)This;
83 { IExtractIconA_AddRef((IExtractIconA*) *ppvObj);
84 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
87 TRACE("-- Interface: E_NOINTERFACE\n");
91 /**************************************************************************
92 * IExtractIconA_AddRef
94 static ULONG WINAPI IExtractIconA_fnAddRef(IExtractIconA * iface)
96 ICOM_THIS(IExtractIconAImpl,iface);
98 TRACE("(%p)->(count=%lu)\n",This, This->ref );
102 return ++(This->ref);
104 /**************************************************************************
105 * IExtractIconA_Release
107 static ULONG WINAPI IExtractIconA_fnRelease(IExtractIconA * iface)
109 ICOM_THIS(IExtractIconAImpl,iface);
111 TRACE("(%p)->()\n",This);
116 { TRACE(" destroying IExtractIcon(%p)\n",This);
118 HeapFree(GetProcessHeap(),0,This);
123 /**************************************************************************
124 * IExtractIconA_GetIconLocation
126 * mapping filetype to icon
128 static HRESULT WINAPI IExtractIconA_fnGetIconLocation(
129 IExtractIconA * iface,
136 ICOM_THIS(IExtractIconAImpl,iface);
138 char sTemp[MAX_PATH];
141 LPITEMIDLIST pSimplePidl = ILFindLastID(This->pidl);
143 TRACE("(%p) (flags=%u %p %u %p %p)\n", This, uFlags, szIconFile, cchMax, piIndex, pwFlags);
148 if (_ILIsDesktop(pSimplePidl))
150 lstrcpynA(szIconFile, "shell32.dll", cchMax);
154 /* my computer and other shell extensions */
155 else if ( (riid = _ILGetGUIDPointer(pSimplePidl)) )
158 sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
159 riid->Data1, riid->Data2, riid->Data3,
160 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
161 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
163 if (HCR_GetDefaultIcon(xriid, sTemp, MAX_PATH, &dwNr))
165 lstrcpynA(szIconFile, sTemp, cchMax);
170 lstrcpynA(szIconFile, "shell32.dll", cchMax);
175 else if (_ILIsDrive (pSimplePidl))
177 if (HCR_GetDefaultIcon("Drive", sTemp, MAX_PATH, &dwNr))
179 lstrcpynA(szIconFile, sTemp, cchMax);
184 lstrcpynA(szIconFile, "shell32.dll", cchMax);
188 else if (_ILIsFolder (pSimplePidl))
190 if (HCR_GetDefaultIcon("Folder", sTemp, MAX_PATH, &dwNr))
192 lstrcpynA(szIconFile, sTemp, cchMax);
197 lstrcpynA(szIconFile, "shell32.dll", cchMax);
198 *piIndex = (uFlags & GIL_OPENICON)? 4 : 3;
201 else /* object is file */
203 if (_ILGetExtension (pSimplePidl, sTemp, MAX_PATH)
204 && HCR_MapTypeToValue(sTemp, sTemp, MAX_PATH, TRUE)
205 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
207 if (!strcmp("%1",sTemp)) /* icon is in the file */
209 SHGetPathFromIDListA(This->pidl, sTemp);
212 lstrcpynA(szIconFile, sTemp, cchMax);
215 else /* default icon */
217 lstrcpynA(szIconFile, "shell32.dll", cchMax);
222 TRACE("-- %s %x\n", szIconFile, *piIndex);
225 /**************************************************************************
226 * IExtractIconA_Extract
228 static HRESULT WINAPI IExtractIconA_fnExtract(IExtractIconA * iface, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
230 ICOM_THIS(IExtractIconAImpl,iface);
232 FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
235 *phiconLarge = pImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
238 *phiconSmall = pImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
243 static struct ICOM_VTABLE(IExtractIconA) eivt =
245 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
246 IExtractIconA_fnQueryInterface,
247 IExtractIconA_fnAddRef,
248 IExtractIconA_fnRelease,
249 IExtractIconA_fnGetIconLocation,
250 IExtractIconA_fnExtract
253 /************************************************************************
254 * IEIPersistFile_QueryInterface (IUnknown)
256 static HRESULT WINAPI IEIPersistFile_fnQueryInterface(
261 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
263 return IShellFolder_QueryInterface((IExtractIconA*)This, iid, ppvObj);
266 /************************************************************************
267 * IEIPersistFile_AddRef (IUnknown)
269 static ULONG WINAPI IEIPersistFile_fnAddRef(
272 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
274 return IExtractIconA_AddRef((IExtractIconA*)This);
277 /************************************************************************
278 * IEIPersistFile_Release (IUnknown)
280 static ULONG WINAPI IEIPersistFile_fnRelease(
283 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
285 return IExtractIconA_Release((IExtractIconA*)This);
288 /************************************************************************
289 * IEIPersistFile_GetClassID (IPersist)
291 static HRESULT WINAPI IEIPersistFile_fnGetClassID(
295 CLSID StdFolderID = { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
300 memcpy(lpClassId, &StdFolderID, sizeof(StdFolderID));
305 /************************************************************************
306 * IEIPersistFile_Load (IPersistFile)
308 static HRESULT WINAPI IEIPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
310 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
316 static struct ICOM_VTABLE(IPersistFile) pfvt =
318 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
319 IEIPersistFile_fnQueryInterface,
320 IEIPersistFile_fnAddRef,
321 IEIPersistFile_fnRelease,
322 IEIPersistFile_fnGetClassID,
323 (void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */,
324 IEIPersistFile_fnLoad,
325 (void *) 0xdeadbeef /* IEIPersistFile_fnSave */,
326 (void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
327 (void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */