2 * Copyright 1997 Marcus Meissner
3 * Copyright 1998 Juergen Schmied
10 #include "wine/obj_base.h"
11 #include "wine/obj_extracticon.h"
13 #include "debugtools.h"
17 #include "shell32_main.h"
19 DEFAULT_DEBUG_CHANNEL(shell
)
22 /***********************************************************************
23 * IExtractIconA implementation
27 { ICOM_VTABLE(IExtractIconA
)* lpvtbl
;
29 ICOM_VTABLE(IPersistFile
)* lpvtblPersistFile
;
33 static struct ICOM_VTABLE(IExtractIconA
) eivt
;
34 static struct ICOM_VTABLE(IPersistFile
) pfvt
;
36 #define _IPersistFile_Offset ((int)(&(((IExtractIconAImpl*)0)->lpvtblPersistFile)))
37 #define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
39 /**************************************************************************
40 * IExtractIconA_Constructor
42 IExtractIconA
* IExtractIconA_Constructor(LPCITEMIDLIST pidl
)
44 IExtractIconAImpl
* ei
;
46 ei
=(IExtractIconAImpl
*)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconAImpl
));
49 ei
->lpvtblPersistFile
= &pfvt
;
50 ei
->pidl
=ILClone(pidl
);
56 return (IExtractIconA
*)ei
;
58 /**************************************************************************
59 * IExtractIconA_QueryInterface
61 static HRESULT WINAPI
IExtractIconA_fnQueryInterface( IExtractIconA
* iface
, REFIID riid
, LPVOID
*ppvObj
)
63 ICOM_THIS(IExtractIconAImpl
,iface
);
66 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
67 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This
,xriid
,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 static HRESULT WINAPI
IExtractIconA_fnGetIconLocation(
126 IExtractIconA
* iface
,
133 ICOM_THIS(IExtractIconAImpl
,iface
);
135 char sTemp
[MAX_PATH
];
136 DWORD ret
= S_FALSE
, dwNr
;
137 LPITEMIDLIST pSimplePidl
= ILFindLastID(This
->pidl
);
139 TRACE("(%p) (flags=%u %p %u %p %p)\n", This
, uFlags
, szIconFile
, cchMax
, piIndex
, pwFlags
);
144 if (_ILIsDesktop(pSimplePidl
))
145 { strncpy(szIconFile
, "shell32.dll", cchMax
);
149 else if (_ILIsMyComputer(pSimplePidl
))
150 { if (HCR_GetDefaultIcon("CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}", sTemp
, MAX_PATH
, &dwNr
))
151 { strncpy(szIconFile
, sTemp
, cchMax
);
155 { strncpy(szIconFile
, "shell32.dll", cchMax
);
160 else if (_ILIsDrive (pSimplePidl
))
161 { if (HCR_GetDefaultIcon("Drive", sTemp
, MAX_PATH
, &dwNr
))
162 { strncpy(szIconFile
, sTemp
, cchMax
);
166 { strncpy(szIconFile
, "shell32.dll", cchMax
);
171 else if (_ILIsFolder (pSimplePidl
))
172 { if (HCR_GetDefaultIcon("Folder", sTemp
, MAX_PATH
, &dwNr
))
173 { strncpy(szIconFile
, sTemp
, cchMax
);
177 { strncpy(szIconFile
, "shell32.dll", cchMax
);
183 { if (_ILGetExtension (pSimplePidl
, sTemp
, MAX_PATH
)) /* object is file */
184 { if ( HCR_MapTypeToValue(sTemp
, sTemp
, MAX_PATH
))
185 { if (HCR_GetDefaultIcon(sTemp
, sTemp
, MAX_PATH
, &dwNr
))
186 { if (!strcmp("%1",sTemp
)) /* icon is in the file */
187 { _ILGetPidlPath(This
->pidl
, sTemp
, MAX_PATH
);
190 strncpy(szIconFile
, sTemp
, cchMax
);
198 TRACE("-- %s %x\n", (ret
==NOERROR
)?debugstr_a(szIconFile
):"[error]", *piIndex
);
201 /**************************************************************************
202 * IExtractIconA_Extract
204 static HRESULT WINAPI
IExtractIconA_fnExtract(IExtractIconA
* iface
, LPCSTR pszFile
, UINT nIconIndex
, HICON
*phiconLarge
, HICON
*phiconSmall
, UINT nIconSize
)
206 ICOM_THIS(IExtractIconAImpl
,iface
);
208 FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This
, pszFile
, nIconIndex
, phiconLarge
, phiconSmall
, nIconSize
);
211 *phiconLarge
= pImageList_GetIcon(ShellBigIconList
, nIconIndex
, ILD_TRANSPARENT
);
214 *phiconSmall
= pImageList_GetIcon(ShellSmallIconList
, nIconIndex
, ILD_TRANSPARENT
);
219 static struct ICOM_VTABLE(IExtractIconA
) eivt
=
221 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
222 IExtractIconA_fnQueryInterface
,
223 IExtractIconA_fnAddRef
,
224 IExtractIconA_fnRelease
,
225 IExtractIconA_fnGetIconLocation
,
226 IExtractIconA_fnExtract
229 /************************************************************************
230 * IEIPersistFile_QueryInterface (IUnknown)
232 static HRESULT WINAPI
IEIPersistFile_fnQueryInterface(
237 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
239 return IShellFolder_QueryInterface((IExtractIconA
*)This
, iid
, ppvObj
);
242 /************************************************************************
243 * IEIPersistFile_AddRef (IUnknown)
245 static ULONG WINAPI
IEIPersistFile_fnAddRef(
248 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
250 return IExtractIconA_AddRef((IExtractIconA
*)This
);
253 /************************************************************************
254 * IEIPersistFile_Release (IUnknown)
256 static ULONG WINAPI
IEIPersistFile_fnRelease(
259 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
261 return IExtractIconA_Release((IExtractIconA
*)This
);
264 /************************************************************************
265 * IEIPersistFile_GetClassID (IPersist)
267 static HRESULT WINAPI
IEIPersistFile_fnGetClassID(
268 const IPersistFile
*iface
,
271 CLSID StdFolderID
= { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
276 memcpy(lpClassId
, &StdFolderID
, sizeof(StdFolderID
));
281 /************************************************************************
282 * IEIPersistFile_Load (IPersistFile)
284 static HRESULT WINAPI
IEIPersistFile_fnLoad(IPersistFile
* iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
286 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
292 static struct ICOM_VTABLE(IPersistFile
) pfvt
=
294 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
295 IEIPersistFile_fnQueryInterface
,
296 IEIPersistFile_fnAddRef
,
297 IEIPersistFile_fnRelease
,
298 IEIPersistFile_fnGetClassID
,
299 (void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */,
300 IEIPersistFile_fnLoad
,
301 (void *) 0xdeadbeef /* IEIPersistFile_fnSave */,
302 (void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
303 (void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */