Added version information for Win98.
[wine.git] / dlls / shell32 / folders.c
blobf83082ed27cb45162abb1624f799de3495a032d0
1 /*
2 * Copyright 1997 Marcus Meissner
3 * Copyright 1998 Juergen Schmied
5 */
7 #include <stdlib.h>
8 #include <string.h>
10 #include "wine/obj_base.h"
11 #include "wine/obj_extracticon.h"
13 #include "debugtools.h"
14 #include "winerror.h"
16 #include "pidl.h"
17 #include "shell32_main.h"
19 DEFAULT_DEBUG_CHANNEL(shell)
22 /***********************************************************************
23 * IExtractIconA implementation
26 typedef struct
27 { ICOM_VTABLE(IExtractIconA)* lpvtbl;
28 DWORD ref;
29 ICOM_VTABLE(IPersistFile)* lpvtblPersistFile;
30 LPITEMIDLIST pidl;
31 } IExtractIconAImpl;
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));
47 ei->ref=1;
48 ei->lpvtbl = &eivt;
49 ei->lpvtblPersistFile = &pfvt;
50 ei->pidl=ILClone(pidl);
52 pdump(pidl);
54 TRACE("(%p)\n",ei);
55 shell32_ObjCount++;
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);
65 char xriid[50];
66 WINE_StringFromCLSID((LPCLSID)riid,xriid);
67 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
69 *ppvObj = NULL;
71 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
72 { *ppvObj = This;
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;
81 if(*ppvObj)
82 { IExtractIconA_AddRef((IExtractIconA*) *ppvObj);
83 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
84 return S_OK;
86 TRACE("-- Interface: E_NOINTERFACE\n");
87 return E_NOINTERFACE;
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 );
99 shell32_ObjCount++;
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);
112 shell32_ObjCount--;
114 if (!--(This->ref))
115 { TRACE(" destroying IExtractIcon(%p)\n",This);
116 SHFree(This->pidl);
117 HeapFree(GetProcessHeap(),0,This);
118 return 0;
120 return This->ref;
122 /**************************************************************************
123 * IExtractIconA_GetIconLocation
125 static HRESULT WINAPI IExtractIconA_fnGetIconLocation(
126 IExtractIconA * iface,
127 UINT uFlags,
128 LPSTR szIconFile,
129 UINT cchMax,
130 int * piIndex,
131 UINT * pwFlags)
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);
141 if (pwFlags)
142 *pwFlags = 0;
144 if (_ILIsDesktop(pSimplePidl))
145 { strncpy(szIconFile, "shell32.dll", cchMax);
146 *piIndex = 34;
147 ret = NOERROR;
149 else if (_ILIsMyComputer(pSimplePidl))
150 { if (HCR_GetDefaultIcon("CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}", sTemp, MAX_PATH, &dwNr))
151 { strncpy(szIconFile, sTemp, cchMax);
152 *piIndex = dwNr;
154 else
155 { strncpy(szIconFile, "shell32.dll", cchMax);
156 *piIndex = 15;
158 ret = NOERROR;
160 else if (_ILIsDrive (pSimplePidl))
161 { if (HCR_GetDefaultIcon("Drive", sTemp, MAX_PATH, &dwNr))
162 { strncpy(szIconFile, sTemp, cchMax);
163 *piIndex = dwNr;
165 else
166 { strncpy(szIconFile, "shell32.dll", cchMax);
167 *piIndex = 8;
169 ret = NOERROR;
171 else if (_ILIsFolder (pSimplePidl))
172 { if (HCR_GetDefaultIcon("Folder", sTemp, MAX_PATH, &dwNr))
173 { strncpy(szIconFile, sTemp, cchMax);
174 *piIndex = dwNr;
176 else
177 { strncpy(szIconFile, "shell32.dll", cchMax);
178 *piIndex = 3;
180 ret = NOERROR;
182 else
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);
188 dwNr = 0;
190 strncpy(szIconFile, sTemp, cchMax);
191 *piIndex = dwNr;
192 ret = NOERROR;
198 TRACE("-- %s %x\n", (ret==NOERROR)?debugstr_a(szIconFile):"[error]", *piIndex);
199 return ret;
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);
210 if (phiconLarge)
211 *phiconLarge = pImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
213 if (phiconSmall)
214 *phiconSmall = pImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
216 return S_OK;
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(
233 IPersistFile *iface,
234 REFIID iid,
235 LPVOID *ppvObj)
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(
246 IPersistFile *iface)
248 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
250 return IExtractIconA_AddRef((IExtractIconA*)This);
253 /************************************************************************
254 * IEIPersistFile_Release (IUnknown)
256 static ULONG WINAPI IEIPersistFile_fnRelease(
257 IPersistFile *iface)
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,
269 LPCLSID lpClassId)
271 CLSID StdFolderID = { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
273 if (lpClassId==NULL)
274 return E_POINTER;
276 memcpy(lpClassId, &StdFolderID, sizeof(StdFolderID));
278 return S_OK;
281 /************************************************************************
282 * IEIPersistFile_Load (IPersistFile)
284 static HRESULT WINAPI IEIPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
286 _ICOM_THIS_From_IPersistFile(IExtractIconA, iface);
287 FIXME("%p\n", This);
288 return E_NOTIMPL;
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 */