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_VFIELD(IExtractIconA
);
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
));
49 ICOM_VTBL(ei
) = &eivt
;
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
);
66 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This
,debugstr_guid(riid
),ppvObj
);
70 if(IsEqualIID(riid
, &IID_IUnknown
)) /*IUnknown*/
73 else if(IsEqualIID(riid
, &IID_IPersistFile
)) /*IExtractIcon*/
74 { *ppvObj
= (IPersistFile
*)&(This
->lpvtblPersistFile
);
76 else if(IsEqualIID(riid
, &IID_IExtractIconA
)) /*IExtractIcon*/
77 { *ppvObj
= (IExtractIconA
*)This
;
81 { IExtractIconA_AddRef((IExtractIconA
*) *ppvObj
);
82 TRACE("-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
85 TRACE("-- Interface: E_NOINTERFACE\n");
89 /**************************************************************************
90 * IExtractIconA_AddRef
92 static ULONG WINAPI
IExtractIconA_fnAddRef(IExtractIconA
* iface
)
94 ICOM_THIS(IExtractIconAImpl
,iface
);
96 TRACE("(%p)->(count=%lu)\n",This
, This
->ref
);
100 return ++(This
->ref
);
102 /**************************************************************************
103 * IExtractIconA_Release
105 static ULONG WINAPI
IExtractIconA_fnRelease(IExtractIconA
* iface
)
107 ICOM_THIS(IExtractIconAImpl
,iface
);
109 TRACE("(%p)->()\n",This
);
114 { TRACE(" destroying IExtractIcon(%p)\n",This
);
116 HeapFree(GetProcessHeap(),0,This
);
121 /**************************************************************************
122 * IExtractIconA_GetIconLocation
124 * mapping filetype to icon
126 static HRESULT WINAPI
IExtractIconA_fnGetIconLocation(
127 IExtractIconA
* iface
,
134 ICOM_THIS(IExtractIconAImpl
,iface
);
136 char sTemp
[MAX_PATH
];
139 LPITEMIDLIST pSimplePidl
= ILFindLastID(This
->pidl
);
141 TRACE("(%p) (flags=%u %p %u %p %p)\n", This
, uFlags
, szIconFile
, cchMax
, piIndex
, pwFlags
);
146 if (_ILIsDesktop(pSimplePidl
))
148 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
152 /* my computer and other shell extensions */
153 else if ( (riid
= _ILGetGUIDPointer(pSimplePidl
)) )
156 strcpy(xriid
,"CLSID\\");
157 WINE_StringFromCLSID((LPCLSID
)riid
,&xriid
[strlen(xriid
)]);
159 if (HCR_GetDefaultIcon(xriid
, sTemp
, MAX_PATH
, &dwNr
))
161 lstrcpynA(szIconFile
, sTemp
, cchMax
);
166 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
171 else if (_ILIsDrive (pSimplePidl
))
173 if (HCR_GetDefaultIcon("Drive", sTemp
, MAX_PATH
, &dwNr
))
175 lstrcpynA(szIconFile
, sTemp
, cchMax
);
180 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
184 else if (_ILIsFolder (pSimplePidl
))
186 if (HCR_GetDefaultIcon("Folder", sTemp
, MAX_PATH
, &dwNr
))
188 lstrcpynA(szIconFile
, sTemp
, cchMax
);
193 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
194 *piIndex
= (uFlags
& GIL_OPENICON
)? 4 : 3;
197 else /* object is file */
199 if (_ILGetExtension (pSimplePidl
, sTemp
, MAX_PATH
)
200 && HCR_MapTypeToValue(sTemp
, sTemp
, MAX_PATH
, TRUE
)
201 && HCR_GetDefaultIcon(sTemp
, sTemp
, MAX_PATH
, &dwNr
))
203 if (!strcmp("%1",sTemp
)) /* icon is in the file */
205 SHGetPathFromIDListA(This
->pidl
, sTemp
);
208 lstrcpynA(szIconFile
, sTemp
, cchMax
);
211 else /* default icon */
213 lstrcpynA(szIconFile
, "shell32.dll", cchMax
);
218 TRACE("-- %s %x\n", szIconFile
, *piIndex
);
221 /**************************************************************************
222 * IExtractIconA_Extract
224 static HRESULT WINAPI
IExtractIconA_fnExtract(IExtractIconA
* iface
, LPCSTR pszFile
, UINT nIconIndex
, HICON
*phiconLarge
, HICON
*phiconSmall
, UINT nIconSize
)
226 ICOM_THIS(IExtractIconAImpl
,iface
);
228 FIXME("(%p) (file=%p index=%u %p %p size=%u) semi-stub\n", This
, pszFile
, nIconIndex
, phiconLarge
, phiconSmall
, nIconSize
);
231 *phiconLarge
= pImageList_GetIcon(ShellBigIconList
, nIconIndex
, ILD_TRANSPARENT
);
234 *phiconSmall
= pImageList_GetIcon(ShellSmallIconList
, nIconIndex
, ILD_TRANSPARENT
);
239 static struct ICOM_VTABLE(IExtractIconA
) eivt
=
241 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
242 IExtractIconA_fnQueryInterface
,
243 IExtractIconA_fnAddRef
,
244 IExtractIconA_fnRelease
,
245 IExtractIconA_fnGetIconLocation
,
246 IExtractIconA_fnExtract
249 /************************************************************************
250 * IEIPersistFile_QueryInterface (IUnknown)
252 static HRESULT WINAPI
IEIPersistFile_fnQueryInterface(
257 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
259 return IShellFolder_QueryInterface((IExtractIconA
*)This
, iid
, ppvObj
);
262 /************************************************************************
263 * IEIPersistFile_AddRef (IUnknown)
265 static ULONG WINAPI
IEIPersistFile_fnAddRef(
268 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
270 return IExtractIconA_AddRef((IExtractIconA
*)This
);
273 /************************************************************************
274 * IEIPersistFile_Release (IUnknown)
276 static ULONG WINAPI
IEIPersistFile_fnRelease(
279 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
281 return IExtractIconA_Release((IExtractIconA
*)This
);
284 /************************************************************************
285 * IEIPersistFile_GetClassID (IPersist)
287 static HRESULT WINAPI
IEIPersistFile_fnGetClassID(
291 CLSID StdFolderID
= { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
296 memcpy(lpClassId
, &StdFolderID
, sizeof(StdFolderID
));
301 /************************************************************************
302 * IEIPersistFile_Load (IPersistFile)
304 static HRESULT WINAPI
IEIPersistFile_fnLoad(IPersistFile
* iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
306 _ICOM_THIS_From_IPersistFile(IExtractIconA
, iface
);
312 static struct ICOM_VTABLE(IPersistFile
) pfvt
=
314 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
315 IEIPersistFile_fnQueryInterface
,
316 IEIPersistFile_fnAddRef
,
317 IEIPersistFile_fnRelease
,
318 IEIPersistFile_fnGetClassID
,
319 (void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */,
320 IEIPersistFile_fnLoad
,
321 (void *) 0xdeadbeef /* IEIPersistFile_fnSave */,
322 (void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
323 (void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */