Commit | Line | Data |
---|---|---|
85ed45e3 | 1 | /* |
85ed45e3 AJ |
2 | * Copyright 1997 Marcus Meissner |
3 | * Copyright 1998 Juergen Schmied | |
4 | * | |
0799c1a7 AJ |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Lesser General Public | |
7 | * License as published by the Free Software Foundation; either | |
8 | * version 2.1 of the License, or (at your option) any later version. | |
9 | * | |
10 | * This library is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this library; if not, write to the Free Software | |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
85ed45e3 AJ |
18 | */ |
19 | ||
0f3d8bf5 MF |
20 | #include "config.h" |
21 | #include "wine/port.h" | |
22 | ||
85ed45e3 | 23 | #include <stdlib.h> |
e37c6e18 | 24 | #include <stdarg.h> |
91791032 | 25 | #include <stdio.h> |
85ed45e3 | 26 | #include <string.h> |
8e7cb4db | 27 | |
486d020c FG |
28 | #define COBJMACROS |
29 | ||
f5cea729 | 30 | #include "windef.h" |
e37c6e18 | 31 | #include "winbase.h" |
8e804681 | 32 | #include "winerror.h" |
1f5315c8 | 33 | #include "objbase.h" |
3954117c | 34 | #include "undocshell.h" |
b08cb175 | 35 | #include "shlguid.h" |
77beaca7 | 36 | #include "winreg.h" |
8e7cb4db | 37 | |
0799c1a7 | 38 | #include "wine/debug.h" |
8e7cb4db | 39 | |
ba28ba17 | 40 | #include "pidl.h" |
85ed45e3 | 41 | #include "shell32_main.h" |
8e804681 | 42 | #include "shfldr.h" |
861282bf | 43 | #include "shresdef.h" |
85ed45e3 | 44 | |
0799c1a7 | 45 | WINE_DEFAULT_DEBUG_CHANNEL(shell); |
b4b9fae6 | 46 | |
8e7cb4db | 47 | /*********************************************************************** |
1b7b3163 | 48 | * IExtractIconW implementation |
85ed45e3 | 49 | */ |
9a624916 | 50 | typedef struct |
1b7b3163 | 51 | { |
eba47f1d | 52 | const IExtractIconWVtbl *lpVtbl; |
e28c014a | 53 | LONG ref; |
eba47f1d DT |
54 | const IPersistFileVtbl *lpvtblPersistFile; |
55 | const IExtractIconAVtbl *lpvtblExtractIconA; | |
0467ce9f | 56 | LPITEMIDLIST pidl; |
1b7b3163 | 57 | } IExtractIconWImpl; |
8e7cb4db | 58 | |
eba47f1d DT |
59 | static const IExtractIconAVtbl eiavt; |
60 | static const IExtractIconWVtbl eivt; | |
61 | static const IPersistFileVtbl pfvt; | |
85ed45e3 | 62 | |
b1a9701b AJ |
63 | static inline IExtractIconW *impl_from_IPersistFile( IPersistFile *iface ) |
64 | { | |
65 | return (IExtractIconW *)((char*)iface - FIELD_OFFSET(IExtractIconWImpl, lpvtblPersistFile)); | |
66 | } | |
67 | ||
68 | static inline IExtractIconW *impl_from_IExtractIconA( IExtractIconA *iface ) | |
69 | { | |
70 | return (IExtractIconW *)((char*)iface - FIELD_OFFSET(IExtractIconWImpl, lpvtblExtractIconA)); | |
71 | } | |
85ed45e3 | 72 | |
1b7b3163 | 73 | |
85ed45e3 | 74 | /************************************************************************** |
1b7b3163 | 75 | * IExtractIconW_Constructor |
85ed45e3 | 76 | */ |
1b7b3163 | 77 | IExtractIconW* IExtractIconW_Constructor(LPCITEMIDLIST pidl) |
8e7cb4db | 78 | { |
1b7b3163 | 79 | IExtractIconWImpl* ei; |
d7d7e3bc RK |
80 | |
81 | TRACE("%p\n", pidl); | |
72b76d1a | 82 | |
17c31068 | 83 | ei = HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconWImpl)); |
8e7cb4db | 84 | ei->ref=1; |
c2ebe1ff | 85 | ei->lpVtbl = &eivt; |
d0065323 | 86 | ei->lpvtblPersistFile = &pfvt; |
1b7b3163 | 87 | ei->lpvtblExtractIconA = &eiavt; |
8e7cb4db | 88 | ei->pidl=ILClone(pidl); |
72b76d1a | 89 | |
8e7cb4db | 90 | pdump(pidl); |
72b76d1a | 91 | |
1b7b3163 RK |
92 | TRACE("(%p)\n", ei); |
93 | return (IExtractIconW *)ei; | |
85ed45e3 AJ |
94 | } |
95 | /************************************************************************** | |
1b7b3163 | 96 | * IExtractIconW_QueryInterface |
85ed45e3 | 97 | */ |
1b7b3163 | 98 | static HRESULT WINAPI IExtractIconW_fnQueryInterface(IExtractIconW *iface, REFIID riid, LPVOID *ppvObj) |
8e7cb4db | 99 | { |
314b99c4 | 100 | IExtractIconWImpl *This = (IExtractIconWImpl *)iface; |
8e7cb4db | 101 | |
1b7b3163 | 102 | TRACE("(%p)->(\n\tIID:\t%s,%p)\n", This, debugstr_guid(riid), ppvObj); |
8e7cb4db JS |
103 | |
104 | *ppvObj = NULL; | |
105 | ||
1b7b3163 RK |
106 | if (IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/ |
107 | { | |
108 | *ppvObj = This; | |
109 | } | |
110 | else if (IsEqualIID(riid, &IID_IPersistFile)) /*IExtractIcon*/ | |
111 | { | |
112 | *ppvObj = (IPersistFile*)&(This->lpvtblPersistFile); | |
8e7cb4db | 113 | } |
1b7b3163 RK |
114 | else if (IsEqualIID(riid, &IID_IExtractIconA)) /*IExtractIcon*/ |
115 | { | |
116 | *ppvObj = (IExtractIconA*)&(This->lpvtblExtractIconA); | |
d0065323 | 117 | } |
1b7b3163 RK |
118 | else if (IsEqualIID(riid, &IID_IExtractIconW)) /*IExtractIcon*/ |
119 | { | |
120 | *ppvObj = (IExtractIconW*)This; | |
8e7cb4db JS |
121 | } |
122 | ||
123 | if(*ppvObj) | |
1b7b3163 RK |
124 | { |
125 | IExtractIconW_AddRef((IExtractIconW*) *ppvObj); | |
a099a555 | 126 | TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj); |
8e7cb4db JS |
127 | return S_OK; |
128 | } | |
a099a555 | 129 | TRACE("-- Interface: E_NOINTERFACE\n"); |
85ed45e3 | 130 | return E_NOINTERFACE; |
8e7cb4db | 131 | } |
85ed45e3 AJ |
132 | |
133 | /************************************************************************** | |
1b7b3163 | 134 | * IExtractIconW_AddRef |
85ed45e3 | 135 | */ |
1b7b3163 | 136 | static ULONG WINAPI IExtractIconW_fnAddRef(IExtractIconW * iface) |
8e7cb4db | 137 | { |
314b99c4 | 138 | IExtractIconWImpl *This = (IExtractIconWImpl *)iface; |
ba92d292 | 139 | ULONG refCount = InterlockedIncrement(&This->ref); |
8e7cb4db | 140 | |
ba92d292 | 141 | TRACE("(%p)->(count=%lu)\n", This, refCount - 1); |
ba28ba17 | 142 | |
ba92d292 | 143 | return refCount; |
85ed45e3 AJ |
144 | } |
145 | /************************************************************************** | |
1b7b3163 | 146 | * IExtractIconW_Release |
85ed45e3 | 147 | */ |
1b7b3163 | 148 | static ULONG WINAPI IExtractIconW_fnRelease(IExtractIconW * iface) |
8e7cb4db | 149 | { |
314b99c4 | 150 | IExtractIconWImpl *This = (IExtractIconWImpl *)iface; |
ba92d292 | 151 | ULONG refCount = InterlockedDecrement(&This->ref); |
8e7cb4db | 152 | |
ba92d292 | 153 | TRACE("(%p)->(count=%lu)\n", This, refCount + 1); |
ba28ba17 | 154 | |
ba92d292 | 155 | if (!refCount) |
1b7b3163 RK |
156 | { |
157 | TRACE(" destroying IExtractIcon(%p)\n",This); | |
8e7cb4db JS |
158 | SHFree(This->pidl); |
159 | HeapFree(GetProcessHeap(),0,This); | |
160 | return 0; | |
161 | } | |
ba92d292 | 162 | return refCount; |
85ed45e3 | 163 | } |
1b7b3163 | 164 | |
77beaca7 JL |
165 | static HRESULT getIconLocationForFolder(IExtractIconW *iface, UINT uFlags, |
166 | LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags) | |
167 | { | |
314b99c4 | 168 | IExtractIconWImpl *This = (IExtractIconWImpl *)iface; |
77beaca7 | 169 | DWORD dwNr; |
8e804681 RS |
170 | WCHAR wszPath[MAX_PATH]; |
171 | WCHAR wszCLSIDValue[CHARS_IN_GUID]; | |
172 | static const WCHAR shellClassInfo[] = { '.','S','h','e','l','l','C','l','a','s','s','I','n','f','o',0 }; | |
173 | static const WCHAR iconFile[] = { 'I','c','o','n','F','i','l','e',0 }; | |
174 | static const WCHAR clsid[] = { 'C','L','S','I','D',0 }; | |
175 | static const WCHAR clsid2[] = { 'C','L','S','I','D','2',0 }; | |
176 | static const WCHAR iconIndex[] = { 'I','c','o','n','I','n','d','e','x',0 }; | |
177 | ||
178 | if (SHELL32_GetCustomFolderAttribute(This->pidl, shellClassInfo, iconFile, | |
179 | wszPath, MAX_PATH)) | |
77beaca7 | 180 | { |
8e804681 RS |
181 | WCHAR wszIconIndex[10]; |
182 | SHELL32_GetCustomFolderAttribute(This->pidl, shellClassInfo, iconIndex, | |
183 | wszIconIndex, 10); | |
184 | *piIndex = atoiW(wszIconIndex); | |
185 | } | |
186 | else if (SHELL32_GetCustomFolderAttribute(This->pidl, shellClassInfo, clsid, | |
187 | wszCLSIDValue, CHARS_IN_GUID) && | |
188 | HCR_GetDefaultIconW(wszCLSIDValue, szIconFile, cchMax, &dwNr)) | |
189 | { | |
190 | *piIndex = dwNr; | |
191 | } | |
192 | else if (SHELL32_GetCustomFolderAttribute(This->pidl, shellClassInfo, clsid2, | |
193 | wszCLSIDValue, CHARS_IN_GUID) && | |
194 | HCR_GetDefaultIconW(wszCLSIDValue, szIconFile, cchMax, &dwNr)) | |
195 | { | |
196 | *piIndex = dwNr; | |
77beaca7 | 197 | } |
8e804681 | 198 | else |
77beaca7 JL |
199 | { |
200 | static const WCHAR folder[] = { 'F','o','l','d','e','r',0 }; | |
201 | ||
202 | if (!HCR_GetDefaultIconW(folder, szIconFile, cchMax, &dwNr)) | |
203 | { | |
204 | lstrcpynW(szIconFile, swShell32Name, cchMax); | |
861282bf | 205 | dwNr = IDI_SHELL_FOLDER; |
77beaca7 | 206 | } |
861282bf | 207 | *piIndex = -((uFlags & GIL_OPENICON) ? dwNr + 1 : dwNr); |
77beaca7 JL |
208 | } |
209 | return S_OK; | |
210 | } | |
211 | ||
0f3d8bf5 | 212 | WCHAR swShell32Name[MAX_PATH]; |
1b7b3163 | 213 | |
85ed45e3 | 214 | /************************************************************************** |
1b7b3163 | 215 | * IExtractIconW_GetIconLocation |
0fa45f11 JS |
216 | * |
217 | * mapping filetype to icon | |
85ed45e3 | 218 | */ |
1b7b3163 RK |
219 | static HRESULT WINAPI IExtractIconW_fnGetIconLocation( |
220 | IExtractIconW * iface, | |
221 | UINT uFlags, /* GIL_ flags */ | |
222 | LPWSTR szIconFile, | |
d0065323 JS |
223 | UINT cchMax, |
224 | int * piIndex, | |
1b7b3163 | 225 | UINT * pwFlags) /* returned GIL_ flags */ |
8e7cb4db | 226 | { |
314b99c4 | 227 | IExtractIconWImpl *This = (IExtractIconWImpl *)iface; |
72b76d1a | 228 | |
d0065323 | 229 | char sTemp[MAX_PATH]; |
0fa45f11 JS |
230 | DWORD dwNr; |
231 | GUID const * riid; | |
d0065323 | 232 | LPITEMIDLIST pSimplePidl = ILFindLastID(This->pidl); |
9a624916 | 233 | |
a099a555 | 234 | TRACE("(%p) (flags=%u %p %u %p %p)\n", This, uFlags, szIconFile, cchMax, piIndex, pwFlags); |
8e7cb4db | 235 | |
d0065323 JS |
236 | if (pwFlags) |
237 | *pwFlags = 0; | |
a0d77315 | 238 | |
d0065323 | 239 | if (_ILIsDesktop(pSimplePidl)) |
0fa45f11 | 240 | { |
1b7b3163 | 241 | lstrcpynW(szIconFile, swShell32Name, cchMax); |
861282bf | 242 | *piIndex = -IDI_SHELL_DESKTOP; |
d0065323 | 243 | } |
0fa45f11 JS |
244 | |
245 | /* my computer and other shell extensions */ | |
1b7b3163 | 246 | else if ((riid = _ILGetGUIDPointer(pSimplePidl))) |
9a624916 | 247 | { |
77beaca7 JL |
248 | static const WCHAR fmt[] = { 'C','L','S','I','D','\\', |
249 | '{','%','0','8','l','x','-','%','0','4','x','-','%','0','4','x','-', | |
250 | '%','0','2','x','%','0','2','x','-','%','0','2','x', '%','0','2','x', | |
251 | '%','0','2','x','%','0','2','x','%','0','2','x','%','0','2','x','}',0 }; | |
2843de3f | 252 | WCHAR xriid[50]; |
1b7b3163 | 253 | |
2843de3f | 254 | sprintfW(xriid, fmt, |
1b7b3163 RK |
255 | riid->Data1, riid->Data2, riid->Data3, |
256 | riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3], | |
257 | riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7]); | |
0fa45f11 | 258 | |
2843de3f | 259 | if (HCR_GetDefaultIconW(xriid, szIconFile, cchMax, &dwNr)) |
0fa45f11 | 260 | { |
d0065323 JS |
261 | *piIndex = dwNr; |
262 | } | |
263 | else | |
0fa45f11 | 264 | { |
1b7b3163 | 265 | lstrcpynW(szIconFile, swShell32Name, cchMax); |
be428abd HD |
266 | if(IsEqualGUID(riid, &CLSID_MyComputer)) |
267 | *piIndex = -IDI_SHELL_MY_COMPUTER; | |
268 | else if(IsEqualGUID(riid, &CLSID_MyDocuments)) | |
b0b47774 | 269 | *piIndex = -IDI_SHELL_MY_DOCUMENTS; |
be428abd HD |
270 | else if(IsEqualGUID(riid, &CLSID_NetworkPlaces)) |
271 | *piIndex = -IDI_SHELL_MY_NETWORK_PLACES; | |
3c3495ea MJ |
272 | else if(IsEqualGUID(riid, &CLSID_UnixFolder) || |
273 | IsEqualGUID(riid, &CLSID_UnixDosFolder)) | |
94e5f012 | 274 | *piIndex = -IDI_SHELL_DRIVE; |
be428abd HD |
275 | else |
276 | *piIndex = -IDI_SHELL_FOLDER; | |
d0065323 | 277 | } |
d0065323 | 278 | } |
0fa45f11 | 279 | |
d0065323 | 280 | else if (_ILIsDrive (pSimplePidl)) |
0fa45f11 | 281 | { |
77beaca7 | 282 | static const WCHAR drive[] = { 'D','r','i','v','e',0 }; |
2843de3f | 283 | |
72c9008e AJ |
284 | int icon_idx = -1; |
285 | ||
286 | if (_ILGetDrive(pSimplePidl, sTemp, MAX_PATH)) | |
0fa45f11 | 287 | { |
72c9008e AJ |
288 | switch(GetDriveTypeA(sTemp)) |
289 | { | |
861282bf HD |
290 | case DRIVE_REMOVABLE: icon_idx = IDI_SHELL_FLOPPY; break; |
291 | case DRIVE_CDROM: icon_idx = IDI_SHELL_CDROM; break; | |
292 | case DRIVE_REMOTE: icon_idx = IDI_SHELL_NETDRIVE; break; | |
293 | case DRIVE_RAMDISK: icon_idx = IDI_SHELL_RAMDISK; break; | |
72c9008e AJ |
294 | } |
295 | } | |
296 | ||
297 | if (icon_idx != -1) | |
298 | { | |
299 | lstrcpynW(szIconFile, swShell32Name, cchMax); | |
861282bf | 300 | *piIndex = -icon_idx; |
d0065323 JS |
301 | } |
302 | else | |
0fa45f11 | 303 | { |
72c9008e AJ |
304 | if (HCR_GetDefaultIconW(drive, szIconFile, cchMax, &dwNr)) |
305 | { | |
306 | *piIndex = dwNr; | |
307 | } | |
308 | else | |
309 | { | |
310 | lstrcpynW(szIconFile, swShell32Name, cchMax); | |
861282bf | 311 | *piIndex = -IDI_SHELL_DRIVE; |
72c9008e | 312 | } |
d0065323 | 313 | } |
d0065323 JS |
314 | } |
315 | else if (_ILIsFolder (pSimplePidl)) | |
0fa45f11 | 316 | { |
861282bf HD |
317 | getIconLocationForFolder(iface, uFlags, szIconFile, cchMax, piIndex, |
318 | pwFlags); | |
d0065323 | 319 | } |
dd46d6df | 320 | else |
0fa45f11 | 321 | { |
dd46d6df MF |
322 | BOOL found = FALSE; |
323 | ||
324 | if (_ILIsCPanelStruct(pSimplePidl)) | |
325 | { | |
326 | if (SUCCEEDED(CPanel_GetIconLocationW(pSimplePidl, szIconFile, cchMax, piIndex))) | |
327 | found = TRUE; | |
328 | } | |
329 | else if (_ILGetExtension(pSimplePidl, sTemp, MAX_PATH)) | |
0fa45f11 | 330 | { |
dd46d6df MF |
331 | if (HCR_MapTypeToValueA(sTemp, sTemp, MAX_PATH, TRUE) |
332 | && HCR_GetDefaultIconA(sTemp, sTemp, MAX_PATH, &dwNr)) | |
0fa45f11 | 333 | { |
dd46d6df MF |
334 | if (!lstrcmpA("%1", sTemp)) /* icon is in the file */ |
335 | { | |
336 | SHGetPathFromIDListW(This->pidl, szIconFile); | |
337 | *piIndex = 0; | |
338 | } | |
339 | else | |
340 | { | |
341 | MultiByteToWideChar(CP_ACP, 0, sTemp, -1, szIconFile, cchMax); | |
342 | *piIndex = dwNr; | |
343 | } | |
344 | ||
345 | found = TRUE; | |
1b7b3163 | 346 | } |
2c8367a3 | 347 | else if (!lstrcmpiA(sTemp, "lnkfile")) |
1b7b3163 | 348 | { |
d98c36c1 MF |
349 | /* extract icon from shell shortcut */ |
350 | IShellFolder* dsf; | |
351 | IShellLinkW* psl; | |
352 | ||
353 | if (SUCCEEDED(SHGetDesktopFolder(&dsf))) | |
354 | { | |
355 | HRESULT hr = IShellFolder_GetUIObjectOf(dsf, NULL, 1, (LPCITEMIDLIST*)&This->pidl, &IID_IShellLinkW, NULL, (LPVOID*)&psl); | |
356 | ||
357 | if (SUCCEEDED(hr)) | |
358 | { | |
359 | hr = IShellLinkW_GetIconLocation(psl, szIconFile, MAX_PATH, piIndex); | |
360 | ||
361 | if (SUCCEEDED(hr) && *szIconFile) | |
362 | found = TRUE; | |
363 | ||
364 | IShellLinkW_Release(psl); | |
365 | } | |
366 | ||
367 | IShellFolder_Release(dsf); | |
368 | } | |
d0065323 | 369 | } |
0fa45f11 | 370 | } |
d98c36c1 MF |
371 | |
372 | if (!found) /* default icon */ | |
373 | { | |
374 | lstrcpynW(szIconFile, swShell32Name, cchMax); | |
375 | *piIndex = 0; | |
376 | } | |
d0065323 | 377 | } |
72b76d1a | 378 | |
1b7b3163 | 379 | TRACE("-- %s %x\n", debugstr_w(szIconFile), *piIndex); |
0fa45f11 | 380 | return NOERROR; |
85ed45e3 | 381 | } |
dd46d6df | 382 | |
85ed45e3 | 383 | /************************************************************************** |
1b7b3163 | 384 | * IExtractIconW_Extract |
85ed45e3 | 385 | */ |
1b7b3163 | 386 | static HRESULT WINAPI IExtractIconW_fnExtract(IExtractIconW * iface, LPCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) |
8e7cb4db | 387 | { |
314b99c4 | 388 | IExtractIconWImpl *This = (IExtractIconWImpl *)iface; |
861282bf | 389 | int index; |
8e7cb4db | 390 | |
861282bf HD |
391 | FIXME("(%p) (file=%p index=%d %p %p size=%08x) semi-stub\n", This, debugstr_w(pszFile), (signed)nIconIndex, |
392 | phiconLarge, phiconSmall, nIconSize); | |
393 | ||
40cb9826 | 394 | index = SIC_GetIconIndex(pszFile, nIconIndex, 0); |
d0065323 JS |
395 | |
396 | if (phiconLarge) | |
861282bf | 397 | *phiconLarge = ImageList_GetIcon(ShellBigIconList, index, ILD_TRANSPARENT); |
d0065323 JS |
398 | |
399 | if (phiconSmall) | |
861282bf | 400 | *phiconSmall = ImageList_GetIcon(ShellSmallIconList, index, ILD_TRANSPARENT); |
8e7cb4db | 401 | |
8e7cb4db | 402 | return S_OK; |
85ed45e3 AJ |
403 | } |
404 | ||
eba47f1d | 405 | static const IExtractIconWVtbl eivt = |
1b7b3163 | 406 | { |
1b7b3163 RK |
407 | IExtractIconW_fnQueryInterface, |
408 | IExtractIconW_fnAddRef, | |
409 | IExtractIconW_fnRelease, | |
410 | IExtractIconW_fnGetIconLocation, | |
411 | IExtractIconW_fnExtract | |
412 | }; | |
413 | ||
414 | /************************************************************************** | |
415 | * IExtractIconA_Constructor | |
416 | */ | |
417 | IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl) | |
418 | { | |
314b99c4 | 419 | IExtractIconWImpl *This = (IExtractIconWImpl *)IExtractIconW_Constructor(pidl); |
d7d7e3bc RK |
420 | IExtractIconA *eia = (IExtractIconA *)&This->lpvtblExtractIconA; |
421 | ||
422 | TRACE("(%p)->(%p)\n", This, eia); | |
423 | return eia; | |
1b7b3163 RK |
424 | } |
425 | /************************************************************************** | |
426 | * IExtractIconA_QueryInterface | |
427 | */ | |
428 | static HRESULT WINAPI IExtractIconA_fnQueryInterface(IExtractIconA * iface, REFIID riid, LPVOID *ppvObj) | |
429 | { | |
b1a9701b | 430 | IExtractIconW *This = impl_from_IExtractIconA(iface); |
1b7b3163 RK |
431 | |
432 | return IExtractIconW_QueryInterface(This, riid, ppvObj); | |
433 | } | |
434 | ||
435 | /************************************************************************** | |
436 | * IExtractIconA_AddRef | |
437 | */ | |
438 | static ULONG WINAPI IExtractIconA_fnAddRef(IExtractIconA * iface) | |
439 | { | |
b1a9701b | 440 | IExtractIconW *This = impl_from_IExtractIconA(iface); |
1b7b3163 RK |
441 | |
442 | return IExtractIconW_AddRef(This); | |
443 | } | |
444 | /************************************************************************** | |
445 | * IExtractIconA_Release | |
446 | */ | |
447 | static ULONG WINAPI IExtractIconA_fnRelease(IExtractIconA * iface) | |
448 | { | |
b1a9701b | 449 | IExtractIconW *This = impl_from_IExtractIconA(iface); |
1b7b3163 RK |
450 | |
451 | return IExtractIconW_AddRef(This); | |
452 | } | |
453 | /************************************************************************** | |
454 | * IExtractIconA_GetIconLocation | |
455 | * | |
456 | * mapping filetype to icon | |
457 | */ | |
458 | static HRESULT WINAPI IExtractIconA_fnGetIconLocation( | |
459 | IExtractIconA * iface, | |
460 | UINT uFlags, | |
461 | LPSTR szIconFile, | |
462 | UINT cchMax, | |
463 | int * piIndex, | |
464 | UINT * pwFlags) | |
465 | { | |
466 | HRESULT ret; | |
467 | LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, cchMax * sizeof(WCHAR)); | |
b1a9701b | 468 | IExtractIconW *This = impl_from_IExtractIconA(iface); |
1b7b3163 RK |
469 | |
470 | TRACE("(%p) (flags=%u %p %u %p %p)\n", This, uFlags, szIconFile, cchMax, piIndex, pwFlags); | |
471 | ||
472 | ret = IExtractIconW_GetIconLocation(This, uFlags, lpwstrFile, cchMax, piIndex, pwFlags); | |
ea10ed7c | 473 | WideCharToMultiByte(CP_ACP, 0, lpwstrFile, -1, szIconFile, cchMax, NULL, NULL); |
1b7b3163 RK |
474 | HeapFree(GetProcessHeap(), 0, lpwstrFile); |
475 | ||
476 | TRACE("-- %s %x\n", szIconFile, *piIndex); | |
477 | return ret; | |
478 | } | |
479 | /************************************************************************** | |
480 | * IExtractIconA_Extract | |
481 | */ | |
482 | static HRESULT WINAPI IExtractIconA_fnExtract(IExtractIconA * iface, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) | |
483 | { | |
484 | HRESULT ret; | |
485 | INT len = MultiByteToWideChar(CP_ACP, 0, pszFile, -1, NULL, 0); | |
486 | LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); | |
b1a9701b | 487 | IExtractIconW *This = impl_from_IExtractIconA(iface); |
1b7b3163 RK |
488 | |
489 | TRACE("(%p) (file=%p index=%u %p %p size=%u)\n", This, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize); | |
490 | ||
491 | MultiByteToWideChar(CP_ACP, 0, pszFile, -1, lpwstrFile, len); | |
492 | ret = IExtractIconW_Extract(This, lpwstrFile, nIconIndex, phiconLarge, phiconSmall, nIconSize); | |
493 | HeapFree(GetProcessHeap(), 0, lpwstrFile); | |
494 | return ret; | |
495 | } | |
496 | ||
eba47f1d | 497 | static const IExtractIconAVtbl eiavt = |
9a624916 | 498 | { |
2305f3c0 | 499 | IExtractIconA_fnQueryInterface, |
8e7cb4db JS |
500 | IExtractIconA_fnAddRef, |
501 | IExtractIconA_fnRelease, | |
502 | IExtractIconA_fnGetIconLocation, | |
503 | IExtractIconA_fnExtract | |
504 | }; | |
d0065323 JS |
505 | |
506 | /************************************************************************ | |
507 | * IEIPersistFile_QueryInterface (IUnknown) | |
508 | */ | |
509 | static HRESULT WINAPI IEIPersistFile_fnQueryInterface( | |
510 | IPersistFile *iface, | |
511 | REFIID iid, | |
512 | LPVOID *ppvObj) | |
513 | { | |
b1a9701b | 514 | IExtractIconW *This = impl_from_IPersistFile(iface); |
d0065323 | 515 | |
1b7b3163 | 516 | return IExtractIconW_QueryInterface(This, iid, ppvObj); |
d0065323 JS |
517 | } |
518 | ||
519 | /************************************************************************ | |
520 | * IEIPersistFile_AddRef (IUnknown) | |
521 | */ | |
522 | static ULONG WINAPI IEIPersistFile_fnAddRef( | |
523 | IPersistFile *iface) | |
524 | { | |
b1a9701b | 525 | IExtractIconW *This = impl_from_IPersistFile(iface); |
d0065323 | 526 | |
1b7b3163 | 527 | return IExtractIconW_AddRef(This); |
d0065323 JS |
528 | } |
529 | ||
530 | /************************************************************************ | |
531 | * IEIPersistFile_Release (IUnknown) | |
532 | */ | |
533 | static ULONG WINAPI IEIPersistFile_fnRelease( | |
534 | IPersistFile *iface) | |
535 | { | |
b1a9701b | 536 | IExtractIconW *This = impl_from_IPersistFile(iface); |
d0065323 | 537 | |
1b7b3163 | 538 | return IExtractIconW_Release(This); |
d0065323 JS |
539 | } |
540 | ||
541 | /************************************************************************ | |
542 | * IEIPersistFile_GetClassID (IPersist) | |
543 | */ | |
544 | static HRESULT WINAPI IEIPersistFile_fnGetClassID( | |
478eee17 PS |
545 | IPersistFile *iface, |
546 | LPCLSID lpClassId) | |
d0065323 JS |
547 | { |
548 | CLSID StdFolderID = { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; | |
549 | ||
550 | if (lpClassId==NULL) | |
551 | return E_POINTER; | |
552 | ||
553 | memcpy(lpClassId, &StdFolderID, sizeof(StdFolderID)); | |
554 | ||
555 | return S_OK; | |
556 | } | |
557 | ||
558 | /************************************************************************ | |
559 | * IEIPersistFile_Load (IPersistFile) | |
560 | */ | |
561 | static HRESULT WINAPI IEIPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode) | |
562 | { | |
b1a9701b | 563 | IExtractIconW *This = impl_from_IPersistFile(iface); |
a099a555 | 564 | FIXME("%p\n", This); |
d0065323 JS |
565 | return E_NOTIMPL; |
566 | ||
567 | } | |
568 | ||
eba47f1d | 569 | static const IPersistFileVtbl pfvt = |
d0065323 JS |
570 | { |
571 | IEIPersistFile_fnQueryInterface, | |
572 | IEIPersistFile_fnAddRef, | |
573 | IEIPersistFile_fnRelease, | |
574 | IEIPersistFile_fnGetClassID, | |
575 | (void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */, | |
576 | IEIPersistFile_fnLoad, | |
577 | (void *) 0xdeadbeef /* IEIPersistFile_fnSave */, | |
578 | (void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */, | |
579 | (void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */ | |
580 | }; |