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
);
72 return (IExtractIconA
*)ei
;
74 /**************************************************************************
75 * IExtractIconA_QueryInterface
77 static HRESULT WINAPI
IExtractIconA_fnQueryInterface( IExtractIconA
* iface
, REFIID riid
, LPVOID
*ppvObj
)
79 ICOM_THIS(IExtractIconAImpl
,iface
);
81 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This
,debugstr_guid(riid
),ppvObj
);
85 if(IsEqualIID(riid
, &IID_IUnknown
)) /*IUnknown*/
88 else if(IsEqualIID(riid
, &IID_IPersistFile
)) /*IExtractIcon*/
89 { *ppvObj
= (IPersistFile
*)&(This
->lpvtblPersistFile
);
91 else if(IsEqualIID(riid
, &IID_IExtractIconA
)) /*IExtractIcon*/
92 { *ppvObj
= (IExtractIconA
*)This
;
96 { IExtractIconA_AddRef((IExtractIconA
*) *ppvObj
);
97 TRACE("-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
100 TRACE("-- Interface: E_NOINTERFACE\n");
101 return E_NOINTERFACE
;
104 /**************************************************************************
105 * IExtractIconA_AddRef
107 static ULONG WINAPI
IExtractIconA_fnAddRef(IExtractIconA
* iface
)
109 ICOM_THIS(IExtractIconAImpl
,iface
);
111 TRACE("(%p)->(count=%lu)\n",This
, This
->ref
);
113 return ++(This
->ref
);
115 /**************************************************************************
116 * IExtractIconA_Release
118 static ULONG WINAPI
IExtractIconA_fnRelease(IExtractIconA
* iface
)
120 ICOM_THIS(IExtractIconAImpl
,iface
);
122 TRACE("(%p)->()\n",This
);
125 { TRACE(" destroying IExtractIcon(%p)\n",This
);
127 HeapFree(GetProcessHeap(),0,This
);
132 /**************************************************************************
133 * IExtractIconA_GetIconLocation
135 * mapping filetype to icon
137 static HRESULT WINAPI
IExtractIconA_fnGetIconLocation(
138 IExtractIconA
* iface
,
145 ICOM_THIS(IExtractIconAImpl
,iface
);
147 char sTemp
[MAX_PATH
];
150 LPITEMIDLIST pSimplePidl
= ILFindLastID(This
->pidl
);
152 TRACE("(%p) (flags=%u %p %u %p %p)\n", This
, uFlags
, szIconFile
, cchMax
, piIndex
, pwFlags
);
157 if (_ILIsDesktop(pSimplePidl
))
159 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
163 /* my computer and other shell extensions */
164 else if ( (riid
= _ILGetGUIDPointer(pSimplePidl
)) )
167 sprintf( xriid
, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
168 riid
->Data1
, riid
->Data2
, riid
->Data3
,
169 riid
->Data4
[0], riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3],
170 riid
->Data4
[4], riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7] );
172 if (HCR_GetDefaultIcon(xriid
, sTemp
, MAX_PATH
, &dwNr
))
174 lstrcpynA(szIconFile
, sTemp
, cchMax
);
179 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
184 else if (_ILIsDrive (pSimplePidl
))
186 if (HCR_GetDefaultIcon("Drive", sTemp
, MAX_PATH
, &dwNr
))
188 lstrcpynA(szIconFile
, sTemp
, cchMax
);
193 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
197 else if (_ILIsFolder (pSimplePidl
))
199 if (HCR_GetDefaultIcon("Folder", sTemp
, MAX_PATH
, &dwNr
))
201 lstrcpynA(szIconFile
, sTemp
, cchMax
);
206 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
207 *piIndex
= (uFlags
& GIL_OPENICON
)? 4 : 3;
210 else /* object is file */
212 if (_ILGetExtension (pSimplePidl
, sTemp
, MAX_PATH
)
213 && HCR_MapTypeToValue(sTemp
, sTemp
, MAX_PATH
, TRUE
)
214 && HCR_GetDefaultIcon(sTemp
, sTemp
, MAX_PATH
, &dwNr
))
216 if (!strcmp("%1",sTemp
)) /* icon is in the file */
218 SHGetPathFromIDListA(This
->pidl
, sTemp
);
221 lstrcpynA(szIconFile
, sTemp
, cchMax
);
224 else /* default icon */
226 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
231 TRACE("-- %s %x\n", szIconFile
, *piIndex
);
234 /**************************************************************************
235 * IExtractIconA_Extract
237 static HRESULT WINAPI
IExtractIconA_fnExtract(IExtractIconA
* iface
, LPCSTR pszFile
, UINT nIconIndex
, HICON
*phiconLarge
, HICON
*phiconSmall
, UINT nIconSize
)
239 ICOM_THIS(IExtractIconAImpl
,iface
);
241 FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This
, pszFile
, nIconIndex
, phiconLarge
, phiconSmall
, nIconSize
);
244 *phiconLarge
= ImageList_GetIcon(ShellBigIconList
, nIconIndex
, ILD_TRANSPARENT
);
247 *phiconSmall
= ImageList_GetIcon(ShellSmallIconList
, nIconIndex
, ILD_TRANSPARENT
);
252 static struct ICOM_VTABLE(IExtractIconA
) eivt
=
254 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
255 IExtractIconA_fnQueryInterface
,
256 IExtractIconA_fnAddRef
,
257 IExtractIconA_fnRelease
,
258 IExtractIconA_fnGetIconLocation
,
259 IExtractIconA_fnExtract
262 /************************************************************************
263 * IEIPersistFile_QueryInterface (IUnknown)
265 static HRESULT WINAPI
IEIPersistFile_fnQueryInterface(
270 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
272 return IShellFolder_QueryInterface((IExtractIconA
*)This
, iid
, ppvObj
);
275 /************************************************************************
276 * IEIPersistFile_AddRef (IUnknown)
278 static ULONG WINAPI
IEIPersistFile_fnAddRef(
281 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
283 return IExtractIconA_AddRef((IExtractIconA
*)This
);
286 /************************************************************************
287 * IEIPersistFile_Release (IUnknown)
289 static ULONG WINAPI
IEIPersistFile_fnRelease(
292 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
294 return IExtractIconA_Release((IExtractIconA
*)This
);
297 /************************************************************************
298 * IEIPersistFile_GetClassID (IPersist)
300 static HRESULT WINAPI
IEIPersistFile_fnGetClassID(
304 CLSID StdFolderID
= { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
309 memcpy(lpClassId
, &StdFolderID
, sizeof(StdFolderID
));
314 /************************************************************************
315 * IEIPersistFile_Load (IPersistFile)
317 static HRESULT WINAPI
IEIPersistFile_fnLoad(IPersistFile
* iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
319 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
325 static struct ICOM_VTABLE(IPersistFile
) pfvt
=
327 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
328 IEIPersistFile_fnQueryInterface
,
329 IEIPersistFile_fnAddRef
,
330 IEIPersistFile_fnRelease
,
331 IEIPersistFile_fnGetClassID
,
332 (void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */,
333 IEIPersistFile_fnLoad
,
334 (void *) 0xdeadbeef /* IEIPersistFile_fnSave */,
335 (void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
336 (void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */