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
26 #include "undocshell.h"
29 #include "wine/debug.h"
33 #include "shell32_main.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
38 /***********************************************************************
39 * IExtractIconA implementation
43 { ICOM_VFIELD(IExtractIconA
);
45 ICOM_VTABLE(IPersistFile
)* lpvtblPersistFile
;
49 static struct ICOM_VTABLE(IExtractIconA
) eivt
;
50 static struct ICOM_VTABLE(IPersistFile
) pfvt
;
52 #define _IPersistFile_Offset ((int)(&(((IExtractIconAImpl*)0)->lpvtblPersistFile)))
53 #define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
55 /**************************************************************************
56 * IExtractIconA_Constructor
58 IExtractIconA
* IExtractIconA_Constructor(LPCITEMIDLIST pidl
)
60 IExtractIconAImpl
* ei
;
62 ei
=(IExtractIconAImpl
*)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconAImpl
));
64 ICOM_VTBL(ei
) = &eivt
;
65 ei
->lpvtblPersistFile
= &pfvt
;
66 ei
->pidl
=ILClone(pidl
);
71 return (IExtractIconA
*)ei
;
73 /**************************************************************************
74 * IExtractIconA_QueryInterface
76 static HRESULT WINAPI
IExtractIconA_fnQueryInterface( IExtractIconA
* iface
, REFIID riid
, LPVOID
*ppvObj
)
78 ICOM_THIS(IExtractIconAImpl
,iface
);
80 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This
,debugstr_guid(riid
),ppvObj
);
84 if(IsEqualIID(riid
, &IID_IUnknown
)) /*IUnknown*/
87 else if(IsEqualIID(riid
, &IID_IPersistFile
)) /*IExtractIcon*/
88 { *ppvObj
= (IPersistFile
*)&(This
->lpvtblPersistFile
);
90 else if(IsEqualIID(riid
, &IID_IExtractIconA
)) /*IExtractIcon*/
91 { *ppvObj
= (IExtractIconA
*)This
;
95 { IExtractIconA_AddRef((IExtractIconA
*) *ppvObj
);
96 TRACE("-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
99 TRACE("-- Interface: E_NOINTERFACE\n");
100 return E_NOINTERFACE
;
103 /**************************************************************************
104 * IExtractIconA_AddRef
106 static ULONG WINAPI
IExtractIconA_fnAddRef(IExtractIconA
* iface
)
108 ICOM_THIS(IExtractIconAImpl
,iface
);
110 TRACE("(%p)->(count=%lu)\n",This
, This
->ref
);
112 return ++(This
->ref
);
114 /**************************************************************************
115 * IExtractIconA_Release
117 static ULONG WINAPI
IExtractIconA_fnRelease(IExtractIconA
* iface
)
119 ICOM_THIS(IExtractIconAImpl
,iface
);
121 TRACE("(%p)->()\n",This
);
124 { TRACE(" destroying IExtractIcon(%p)\n",This
);
126 HeapFree(GetProcessHeap(),0,This
);
131 /**************************************************************************
132 * IExtractIconA_GetIconLocation
134 * mapping filetype to icon
136 static HRESULT WINAPI
IExtractIconA_fnGetIconLocation(
137 IExtractIconA
* iface
,
144 ICOM_THIS(IExtractIconAImpl
,iface
);
146 char sTemp
[MAX_PATH
];
149 LPITEMIDLIST pSimplePidl
= ILFindLastID(This
->pidl
);
151 TRACE("(%p) (flags=%u %p %u %p %p)\n", This
, uFlags
, szIconFile
, cchMax
, piIndex
, pwFlags
);
156 if (_ILIsDesktop(pSimplePidl
))
158 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
162 /* my computer and other shell extensions */
163 else if ( (riid
= _ILGetGUIDPointer(pSimplePidl
)) )
166 sprintf( xriid
, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
167 riid
->Data1
, riid
->Data2
, riid
->Data3
,
168 riid
->Data4
[0], riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3],
169 riid
->Data4
[4], riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7] );
171 if (HCR_GetDefaultIcon(xriid
, sTemp
, MAX_PATH
, &dwNr
))
173 lstrcpynA(szIconFile
, sTemp
, cchMax
);
178 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
183 else if (_ILIsDrive (pSimplePidl
))
185 if (HCR_GetDefaultIcon("Drive", sTemp
, MAX_PATH
, &dwNr
))
187 lstrcpynA(szIconFile
, sTemp
, cchMax
);
192 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
196 else if (_ILIsFolder (pSimplePidl
))
198 if (HCR_GetDefaultIcon("Folder", sTemp
, MAX_PATH
, &dwNr
))
200 lstrcpynA(szIconFile
, sTemp
, cchMax
);
205 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
206 *piIndex
= (uFlags
& GIL_OPENICON
)? 4 : 3;
209 else /* object is file */
211 if (_ILGetExtension (pSimplePidl
, sTemp
, MAX_PATH
)
212 && HCR_MapTypeToValue(sTemp
, sTemp
, MAX_PATH
, TRUE
)
213 && HCR_GetDefaultIcon(sTemp
, sTemp
, MAX_PATH
, &dwNr
))
215 if (!strcmp("%1",sTemp
)) /* icon is in the file */
217 SHGetPathFromIDListA(This
->pidl
, sTemp
);
220 lstrcpynA(szIconFile
, sTemp
, cchMax
);
223 else /* default icon */
225 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
230 TRACE("-- %s %x\n", szIconFile
, *piIndex
);
233 /**************************************************************************
234 * IExtractIconA_Extract
236 static HRESULT WINAPI
IExtractIconA_fnExtract(IExtractIconA
* iface
, LPCSTR pszFile
, UINT nIconIndex
, HICON
*phiconLarge
, HICON
*phiconSmall
, UINT nIconSize
)
238 ICOM_THIS(IExtractIconAImpl
,iface
);
240 FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This
, pszFile
, nIconIndex
, phiconLarge
, phiconSmall
, nIconSize
);
243 *phiconLarge
= ImageList_GetIcon(ShellBigIconList
, nIconIndex
, ILD_TRANSPARENT
);
246 *phiconSmall
= ImageList_GetIcon(ShellSmallIconList
, nIconIndex
, ILD_TRANSPARENT
);
251 static struct ICOM_VTABLE(IExtractIconA
) eivt
=
253 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
254 IExtractIconA_fnQueryInterface
,
255 IExtractIconA_fnAddRef
,
256 IExtractIconA_fnRelease
,
257 IExtractIconA_fnGetIconLocation
,
258 IExtractIconA_fnExtract
261 /************************************************************************
262 * IEIPersistFile_QueryInterface (IUnknown)
264 static HRESULT WINAPI
IEIPersistFile_fnQueryInterface(
269 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
271 return IShellFolder_QueryInterface((IExtractIconA
*)This
, iid
, ppvObj
);
274 /************************************************************************
275 * IEIPersistFile_AddRef (IUnknown)
277 static ULONG WINAPI
IEIPersistFile_fnAddRef(
280 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
282 return IExtractIconA_AddRef((IExtractIconA
*)This
);
285 /************************************************************************
286 * IEIPersistFile_Release (IUnknown)
288 static ULONG WINAPI
IEIPersistFile_fnRelease(
291 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
293 return IExtractIconA_Release((IExtractIconA
*)This
);
296 /************************************************************************
297 * IEIPersistFile_GetClassID (IPersist)
299 static HRESULT WINAPI
IEIPersistFile_fnGetClassID(
303 CLSID StdFolderID
= { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
308 memcpy(lpClassId
, &StdFolderID
, sizeof(StdFolderID
));
313 /************************************************************************
314 * IEIPersistFile_Load (IPersistFile)
316 static HRESULT WINAPI
IEIPersistFile_fnLoad(IPersistFile
* iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
318 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
324 static struct ICOM_VTABLE(IPersistFile
) pfvt
=
326 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
327 IEIPersistFile_fnQueryInterface
,
328 IEIPersistFile_fnAddRef
,
329 IEIPersistFile_fnRelease
,
330 IEIPersistFile_fnGetClassID
,
331 (void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */,
332 IEIPersistFile_fnLoad
,
333 (void *) 0xdeadbeef /* IEIPersistFile_fnSave */,
334 (void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
335 (void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */