2 * Copyright 1997 Marcus Meissner
3 * Copyright 1998 Juergen Schmied
10 #include "wine/obj_base.h"
11 #include "wine/obj_extracticon.h"
12 #include "wine/undocshell.h"
14 #include "debugtools.h"
18 #include "shell32_main.h"
20 DEFAULT_DEBUG_CHANNEL(shell
)
23 /***********************************************************************
24 * IExtractIconA implementation
28 { ICOM_VTABLE(IExtractIconA
)* lpvtbl
;
30 ICOM_VTABLE(IPersistFile
)* lpvtblPersistFile
;
34 static struct ICOM_VTABLE(IExtractIconA
) eivt
;
35 static struct ICOM_VTABLE(IPersistFile
) pfvt
;
37 #define _IPersistFile_Offset ((int)(&(((IExtractIconAImpl*)0)->lpvtblPersistFile)))
38 #define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
40 /**************************************************************************
41 * IExtractIconA_Constructor
43 IExtractIconA
* IExtractIconA_Constructor(LPCITEMIDLIST pidl
)
45 IExtractIconAImpl
* ei
;
47 ei
=(IExtractIconAImpl
*)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconAImpl
));
50 ei
->lpvtblPersistFile
= &pfvt
;
51 ei
->pidl
=ILClone(pidl
);
57 return (IExtractIconA
*)ei
;
59 /**************************************************************************
60 * IExtractIconA_QueryInterface
62 static HRESULT WINAPI
IExtractIconA_fnQueryInterface( IExtractIconA
* iface
, REFIID riid
, LPVOID
*ppvObj
)
64 ICOM_THIS(IExtractIconAImpl
,iface
);
67 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
68 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This
,xriid
,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 strcpy(xriid
,"CLSID\\");
159 WINE_StringFromCLSID((LPCLSID
)riid
,&xriid
[strlen(xriid
)]);
161 if (HCR_GetDefaultIcon(xriid
, sTemp
, MAX_PATH
, &dwNr
))
163 lstrcpynA(szIconFile
, sTemp
, cchMax
);
168 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
173 else if (_ILIsDrive (pSimplePidl
))
175 if (HCR_GetDefaultIcon("Drive", sTemp
, MAX_PATH
, &dwNr
))
177 lstrcpynA(szIconFile
, sTemp
, cchMax
);
182 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
186 else if (_ILIsFolder (pSimplePidl
))
188 if (HCR_GetDefaultIcon("Folder", sTemp
, MAX_PATH
, &dwNr
))
190 lstrcpynA(szIconFile
, sTemp
, cchMax
);
195 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
199 else /* object is file */
201 if (_ILGetExtension (pSimplePidl
, sTemp
, MAX_PATH
)
202 && HCR_MapTypeToValue(sTemp
, sTemp
, MAX_PATH
)
203 && HCR_GetDefaultIcon(sTemp
, sTemp
, MAX_PATH
, &dwNr
))
205 if (!strcmp("%1",sTemp
)) /* icon is in the file */
207 SHGetPathFromIDListA(This
->pidl
, sTemp
);
210 lstrcpynA(szIconFile
, sTemp
, cchMax
);
213 else /* default icon */
215 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
220 TRACE("-- %s %x\n", szIconFile
, *piIndex
);
223 /**************************************************************************
224 * IExtractIconA_Extract
226 static HRESULT WINAPI
IExtractIconA_fnExtract(IExtractIconA
* iface
, LPCSTR pszFile
, UINT nIconIndex
, HICON
*phiconLarge
, HICON
*phiconSmall
, UINT nIconSize
)
228 ICOM_THIS(IExtractIconAImpl
,iface
);
230 FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This
, pszFile
, nIconIndex
, phiconLarge
, phiconSmall
, nIconSize
);
233 *phiconLarge
= pImageList_GetIcon(ShellBigIconList
, nIconIndex
, ILD_TRANSPARENT
);
236 *phiconSmall
= pImageList_GetIcon(ShellSmallIconList
, nIconIndex
, ILD_TRANSPARENT
);
241 static struct ICOM_VTABLE(IExtractIconA
) eivt
=
243 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
244 IExtractIconA_fnQueryInterface
,
245 IExtractIconA_fnAddRef
,
246 IExtractIconA_fnRelease
,
247 IExtractIconA_fnGetIconLocation
,
248 IExtractIconA_fnExtract
251 /************************************************************************
252 * IEIPersistFile_QueryInterface (IUnknown)
254 static HRESULT WINAPI
IEIPersistFile_fnQueryInterface(
259 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
261 return IShellFolder_QueryInterface((IExtractIconA
*)This
, iid
, ppvObj
);
264 /************************************************************************
265 * IEIPersistFile_AddRef (IUnknown)
267 static ULONG WINAPI
IEIPersistFile_fnAddRef(
270 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
272 return IExtractIconA_AddRef((IExtractIconA
*)This
);
275 /************************************************************************
276 * IEIPersistFile_Release (IUnknown)
278 static ULONG WINAPI
IEIPersistFile_fnRelease(
281 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
283 return IExtractIconA_Release((IExtractIconA
*)This
);
286 /************************************************************************
287 * IEIPersistFile_GetClassID (IPersist)
289 static HRESULT WINAPI
IEIPersistFile_fnGetClassID(
293 CLSID StdFolderID
= { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
298 memcpy(lpClassId
, &StdFolderID
, sizeof(StdFolderID
));
303 /************************************************************************
304 * IEIPersistFile_Load (IPersistFile)
306 static HRESULT WINAPI
IEIPersistFile_fnLoad(IPersistFile
* iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
308 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
314 static struct ICOM_VTABLE(IPersistFile
) pfvt
=
316 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
317 IEIPersistFile_fnQueryInterface
,
318 IEIPersistFile_fnAddRef
,
319 IEIPersistFile_fnRelease
,
320 IEIPersistFile_fnGetClassID
,
321 (void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */,
322 IEIPersistFile_fnLoad
,
323 (void *) 0xdeadbeef /* IEIPersistFile_fnSave */,
324 (void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
325 (void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */