2 * Copyright 1997 Marcus Meissner
3 * Copyright 1998 Juergen Schmied
12 #include "wine/obj_base.h"
13 #include "wine/obj_extracticon.h"
14 #include "wine/undocshell.h"
17 #include "debugtools.h"
21 #include "shell32_main.h"
23 DEFAULT_DEBUG_CHANNEL(shell
);
26 /***********************************************************************
27 * IExtractIconA implementation
31 { ICOM_VFIELD(IExtractIconA
);
33 ICOM_VTABLE(IPersistFile
)* lpvtblPersistFile
;
37 static struct ICOM_VTABLE(IExtractIconA
) eivt
;
38 static struct ICOM_VTABLE(IPersistFile
) pfvt
;
40 #define _IPersistFile_Offset ((int)(&(((IExtractIconAImpl*)0)->lpvtblPersistFile)))
41 #define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
43 /**************************************************************************
44 * IExtractIconA_Constructor
46 IExtractIconA
* IExtractIconA_Constructor(LPCITEMIDLIST pidl
)
48 IExtractIconAImpl
* ei
;
50 ei
=(IExtractIconAImpl
*)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconAImpl
));
52 ICOM_VTBL(ei
) = &eivt
;
53 ei
->lpvtblPersistFile
= &pfvt
;
54 ei
->pidl
=ILClone(pidl
);
60 return (IExtractIconA
*)ei
;
62 /**************************************************************************
63 * IExtractIconA_QueryInterface
65 static HRESULT WINAPI
IExtractIconA_fnQueryInterface( IExtractIconA
* iface
, REFIID riid
, LPVOID
*ppvObj
)
67 ICOM_THIS(IExtractIconAImpl
,iface
);
69 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This
,debugstr_guid(riid
),ppvObj
);
73 if(IsEqualIID(riid
, &IID_IUnknown
)) /*IUnknown*/
76 else if(IsEqualIID(riid
, &IID_IPersistFile
)) /*IExtractIcon*/
77 { *ppvObj
= (IPersistFile
*)&(This
->lpvtblPersistFile
);
79 else if(IsEqualIID(riid
, &IID_IExtractIconA
)) /*IExtractIcon*/
80 { *ppvObj
= (IExtractIconA
*)This
;
84 { IExtractIconA_AddRef((IExtractIconA
*) *ppvObj
);
85 TRACE("-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
88 TRACE("-- Interface: E_NOINTERFACE\n");
92 /**************************************************************************
93 * IExtractIconA_AddRef
95 static ULONG WINAPI
IExtractIconA_fnAddRef(IExtractIconA
* iface
)
97 ICOM_THIS(IExtractIconAImpl
,iface
);
99 TRACE("(%p)->(count=%lu)\n",This
, This
->ref
);
103 return ++(This
->ref
);
105 /**************************************************************************
106 * IExtractIconA_Release
108 static ULONG WINAPI
IExtractIconA_fnRelease(IExtractIconA
* iface
)
110 ICOM_THIS(IExtractIconAImpl
,iface
);
112 TRACE("(%p)->()\n",This
);
117 { TRACE(" destroying IExtractIcon(%p)\n",This
);
119 HeapFree(GetProcessHeap(),0,This
);
124 /**************************************************************************
125 * IExtractIconA_GetIconLocation
127 * mapping filetype to icon
129 static HRESULT WINAPI
IExtractIconA_fnGetIconLocation(
130 IExtractIconA
* iface
,
137 ICOM_THIS(IExtractIconAImpl
,iface
);
139 char sTemp
[MAX_PATH
];
142 LPITEMIDLIST pSimplePidl
= ILFindLastID(This
->pidl
);
144 TRACE("(%p) (flags=%u %p %u %p %p)\n", This
, uFlags
, szIconFile
, cchMax
, piIndex
, pwFlags
);
149 if (_ILIsDesktop(pSimplePidl
))
151 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
155 /* my computer and other shell extensions */
156 else if ( (riid
= _ILGetGUIDPointer(pSimplePidl
)) )
159 sprintf( xriid
, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
160 riid
->Data1
, riid
->Data2
, riid
->Data3
,
161 riid
->Data4
[0], riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3],
162 riid
->Data4
[4], riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7] );
164 if (HCR_GetDefaultIcon(xriid
, sTemp
, MAX_PATH
, &dwNr
))
166 lstrcpynA(szIconFile
, sTemp
, cchMax
);
171 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
176 else if (_ILIsDrive (pSimplePidl
))
178 if (HCR_GetDefaultIcon("Drive", sTemp
, MAX_PATH
, &dwNr
))
180 lstrcpynA(szIconFile
, sTemp
, cchMax
);
185 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
189 else if (_ILIsFolder (pSimplePidl
))
191 if (HCR_GetDefaultIcon("Folder", sTemp
, MAX_PATH
, &dwNr
))
193 lstrcpynA(szIconFile
, sTemp
, cchMax
);
198 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
199 *piIndex
= (uFlags
& GIL_OPENICON
)? 4 : 3;
202 else /* object is file */
204 if (_ILGetExtension (pSimplePidl
, sTemp
, MAX_PATH
)
205 && HCR_MapTypeToValue(sTemp
, sTemp
, MAX_PATH
, TRUE
)
206 && HCR_GetDefaultIcon(sTemp
, sTemp
, MAX_PATH
, &dwNr
))
208 if (!strcmp("%1",sTemp
)) /* icon is in the file */
210 SHGetPathFromIDListA(This
->pidl
, sTemp
);
213 lstrcpynA(szIconFile
, sTemp
, cchMax
);
216 else /* default icon */
218 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
223 TRACE("-- %s %x\n", szIconFile
, *piIndex
);
226 /**************************************************************************
227 * IExtractIconA_Extract
229 static HRESULT WINAPI
IExtractIconA_fnExtract(IExtractIconA
* iface
, LPCSTR pszFile
, UINT nIconIndex
, HICON
*phiconLarge
, HICON
*phiconSmall
, UINT nIconSize
)
231 ICOM_THIS(IExtractIconAImpl
,iface
);
233 FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This
, pszFile
, nIconIndex
, phiconLarge
, phiconSmall
, nIconSize
);
236 *phiconLarge
= pImageList_GetIcon(ShellBigIconList
, nIconIndex
, ILD_TRANSPARENT
);
239 *phiconSmall
= pImageList_GetIcon(ShellSmallIconList
, nIconIndex
, ILD_TRANSPARENT
);
244 static struct ICOM_VTABLE(IExtractIconA
) eivt
=
246 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
247 IExtractIconA_fnQueryInterface
,
248 IExtractIconA_fnAddRef
,
249 IExtractIconA_fnRelease
,
250 IExtractIconA_fnGetIconLocation
,
251 IExtractIconA_fnExtract
254 /************************************************************************
255 * IEIPersistFile_QueryInterface (IUnknown)
257 static HRESULT WINAPI
IEIPersistFile_fnQueryInterface(
262 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
264 return IShellFolder_QueryInterface((IExtractIconA
*)This
, iid
, ppvObj
);
267 /************************************************************************
268 * IEIPersistFile_AddRef (IUnknown)
270 static ULONG WINAPI
IEIPersistFile_fnAddRef(
273 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
275 return IExtractIconA_AddRef((IExtractIconA
*)This
);
278 /************************************************************************
279 * IEIPersistFile_Release (IUnknown)
281 static ULONG WINAPI
IEIPersistFile_fnRelease(
284 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
286 return IExtractIconA_Release((IExtractIconA
*)This
);
289 /************************************************************************
290 * IEIPersistFile_GetClassID (IPersist)
292 static HRESULT WINAPI
IEIPersistFile_fnGetClassID(
296 CLSID StdFolderID
= { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
301 memcpy(lpClassId
, &StdFolderID
, sizeof(StdFolderID
));
306 /************************************************************************
307 * IEIPersistFile_Load (IPersistFile)
309 static HRESULT WINAPI
IEIPersistFile_fnLoad(IPersistFile
* iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
311 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
317 static struct ICOM_VTABLE(IPersistFile
) pfvt
=
319 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
320 IEIPersistFile_fnQueryInterface
,
321 IEIPersistFile_fnAddRef
,
322 IEIPersistFile_fnRelease
,
323 IEIPersistFile_fnGetClassID
,
324 (void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */,
325 IEIPersistFile_fnLoad
,
326 (void *) 0xdeadbeef /* IEIPersistFile_fnSave */,
327 (void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
328 (void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */