allow only shell links to single objects
[reactos.git] / reactos / lib / shell32 / shfldr_desktop.c
1
2 /*
3 * Virtual Desktop Folder
4 *
5 * Copyright 1997 Marcus Meissner
6 * Copyright 1998, 1999, 2002 Juergen Schmied
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23 #include "config.h"
24 #include "wine/port.h"
25
26 #include <stdlib.h>
27 #include <string.h>
28 #include <stdarg.h>
29 #include <stdio.h>
30
31 #define NONAMELESSUNION
32 #define NONAMELESSSTRUCT
33 #include "winerror.h"
34 #include "windef.h"
35 #include "winbase.h"
36 #include "winreg.h"
37 #include "wingdi.h"
38 #include "winuser.h"
39
40 #include "ole2.h"
41 #include "shlguid.h"
42
43 #include "pidl.h"
44 #include "undocshell.h"
45 #include "shell32_main.h"
46 #include "shresdef.h"
47 #include "shlwapi.h"
48 #include "shellfolder.h"
49 #include "wine/debug.h"
50 #include "debughlp.h"
51 #include "shfldr.h"
52
53 WINE_DEFAULT_DEBUG_CHANNEL (shell);
54
55 /***********************************************************************
56 * Desktopfolder implementation
57 */
58
59 typedef struct {
60 ICOM_VFIELD (IShellFolder2);
61 DWORD ref;
62
63 CLSID *pclsid;
64
65 /* both paths are parsible from the desktop */
66 LPSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */
67 LPITEMIDLIST pidlRoot; /* absolute pidl */
68
69 int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */
70
71 UINT cfShellIDList; /* clipboardformat for IDropTarget */
72 BOOL fAcceptFmt; /* flag for pending Drop */
73 } IGenericSFImpl;
74
75 #define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl)
76 #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
77
78 static struct ICOM_VTABLE (IShellFolder2) vt_MCFldr_ShellFolder2;
79
80 static shvheader DesktopSFHeader[] = {
81 {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
82 {IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
83 {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
84 {IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12},
85 {IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5}
86 };
87
88 #define DESKTOPSHELLVIEWCOLUMNS 5
89
90 /**************************************************************************
91 * ISF_Desktop_Constructor
92 */
93 HRESULT WINAPI ISF_Desktop_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
94 {
95 IGenericSFImpl *sf;
96 char szMyPath[MAX_PATH];
97
98 TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
99
100 if (!ppv)
101 return E_POINTER;
102 if (pUnkOuter)
103 return CLASS_E_NOAGGREGATION;
104
105 if (!SHGetSpecialFolderPathA (0, szMyPath, CSIDL_DESKTOPDIRECTORY, TRUE))
106 return E_UNEXPECTED;
107
108 sf = (IGenericSFImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl));
109 if (!sf)
110 return E_OUTOFMEMORY;
111
112 sf->ref = 0;
113 sf->lpVtbl = &vt_MCFldr_ShellFolder2;
114 sf->pidlRoot = _ILCreateDesktop (); /* my qualified pidl */
115 sf->sPathTarget = SHAlloc (strlen (szMyPath) + 1);
116 lstrcpyA (sf->sPathTarget, szMyPath);
117
118 if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) {
119 IUnknown_Release (_IUnknown_ (sf));
120 return E_NOINTERFACE;
121 }
122
123 TRACE ("--(%p)\n", sf);
124 return S_OK;
125 }
126
127 /**************************************************************************
128 * ISF_Desktop_fnQueryInterface
129 *
130 * NOTES supports not IPersist/IPersistFolder
131 */
132 static HRESULT WINAPI ISF_Desktop_fnQueryInterface (IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj)
133 {
134 ICOM_THIS (IGenericSFImpl, iface);
135
136 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
137
138 *ppvObj = NULL;
139
140 if (IsEqualIID (riid, &IID_IUnknown) || IsEqualIID (riid, &IID_IShellFolder)
141 || IsEqualIID (riid, &IID_IShellFolder2)) {
142 *ppvObj = This;
143 }
144
145 if (*ppvObj) {
146 IUnknown_AddRef ((IUnknown *) (*ppvObj));
147 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
148 return S_OK;
149 }
150 TRACE ("-- Interface: E_NOINTERFACE\n");
151 return E_NOINTERFACE;
152 }
153
154 static ULONG WINAPI ISF_Desktop_fnAddRef (IShellFolder2 * iface)
155 {
156 ICOM_THIS (IGenericSFImpl, iface);
157
158 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
159
160 return ++(This->ref);
161 }
162
163 static ULONG WINAPI ISF_Desktop_fnRelease (IShellFolder2 * iface)
164 {
165 ICOM_THIS (IGenericSFImpl, iface);
166
167 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
168
169 if (!--(This->ref)) {
170 TRACE ("-- destroying IShellFolder(%p)\n", This);
171 if (This->pidlRoot)
172 SHFree (This->pidlRoot);
173 if (This->sPathTarget)
174 SHFree (This->sPathTarget);
175 LocalFree ((HLOCAL) This);
176 return 0;
177 }
178 return This->ref;
179 }
180
181 /**************************************************************************
182 * ISF_Desktop_fnParseDisplayName
183 *
184 * NOTES
185 * "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds
186 * to MyComputer
187 */
188 static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface,
189 HWND hwndOwner,
190 LPBC pbc,
191 LPOLESTR lpszDisplayName,
192 DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
193 {
194 ICOM_THIS (IGenericSFImpl, iface);
195
196 WCHAR szElement[MAX_PATH];
197 LPCWSTR szNext = NULL;
198 LPITEMIDLIST pidlTemp = NULL;
199 HRESULT hr = E_INVALIDARG;
200 char szPath[MAX_PATH];
201 DWORD len;
202 CLSID clsid;
203
204 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
205 This, hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName), pchEaten, ppidl, pdwAttributes);
206
207 if (!lpszDisplayName || !ppidl)
208 return E_INVALIDARG;
209
210 *ppidl = 0;
211
212 if (pchEaten)
213 *pchEaten = 0; /* strange but like the original */
214
215 if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') {
216 szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
217 TRACE ("-- element: %s\n", debugstr_w (szElement));
218 SHCLSIDFromStringW (szElement + 2, &clsid);
219 pidlTemp = _ILCreate (PT_MYCOMP, &clsid, sizeof (clsid));
220 } else if (PathGetDriveNumberW (lpszDisplayName) >= 0) {
221 /* it's a filesystem path with a drive. Let MyComputer parse it */
222 pidlTemp = _ILCreateMyComputer ();
223 szNext = lpszDisplayName;
224 } else if (PathIsUNCW(lpszDisplayName)) {
225 pidlTemp = _ILCreateNetwork();
226 szNext = lpszDisplayName;
227 } else {
228 /* it's a filesystem path on the desktop. Let a FSFolder parse it */
229
230 /* build a complete path to create a simple pidl */
231 lstrcpyA(szPath, This->sPathTarget);
232 PathAddBackslashA(szPath);
233 len = lstrlenA(szPath);
234 WideCharToMultiByte(CP_ACP, 0, lpszDisplayName, -1, szPath + len, MAX_PATH - len, NULL, NULL);
235 pidlTemp = _ILCreateFromPathA(szPath);
236 szNext = NULL;
237 }
238
239 if (pidlTemp) {
240 if (szNext && *szNext) {
241 hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
242 } else {
243 hr = S_OK;
244 if (pdwAttributes && *pdwAttributes) {
245 SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes);
246 }
247 }
248 }
249
250 *ppidl = pidlTemp;
251
252 TRACE ("(%p)->(-- ret=0x%08lx)\n", This, hr);
253
254 return hr;
255 }
256
257 /**************************************************************************
258 * ISF_Desktop_fnEnumObjects
259 */
260 static HRESULT WINAPI ISF_Desktop_fnEnumObjects (IShellFolder2 * iface,
261 HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
262 {
263 ICOM_THIS (IGenericSFImpl, iface);
264
265 TRACE ("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList);
266
267 *ppEnumIDList = NULL;
268 *ppEnumIDList = IEnumIDList_Constructor (NULL, dwFlags, EIDL_DESK);
269
270 TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);
271
272 if (!*ppEnumIDList)
273 return E_OUTOFMEMORY;
274
275 return S_OK;
276 }
277
278 /**************************************************************************
279 * ISF_Desktop_fnBindToObject
280 */
281 static HRESULT WINAPI ISF_Desktop_fnBindToObject (IShellFolder2 * iface,
282 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
283 {
284 ICOM_THIS (IGenericSFImpl, iface);
285
286 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
287
288 return SHELL32_BindToChild (This->pidlRoot, This->sPathTarget, pidl, riid, ppvOut);
289 }
290
291 /**************************************************************************
292 * ISF_Desktop_fnBindToStorage
293 */
294 static HRESULT WINAPI ISF_Desktop_fnBindToStorage (IShellFolder2 * iface,
295 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
296 {
297 ICOM_THIS (IGenericSFImpl, iface);
298
299 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
300
301 *ppvOut = NULL;
302 return E_NOTIMPL;
303 }
304
305 /**************************************************************************
306 * ISF_Desktop_fnCompareIDs
307 */
308
309 static HRESULT WINAPI ISF_Desktop_fnCompareIDs (IShellFolder2 * iface,
310 LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
311 {
312 ICOM_THIS (IGenericSFImpl, iface);
313
314 int nReturn;
315
316 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
317 nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2);
318 TRACE ("-- %i\n", nReturn);
319 return nReturn;
320 }
321
322 /**************************************************************************
323 * ISF_Desktop_fnCreateViewObject
324 */
325 static HRESULT WINAPI ISF_Desktop_fnCreateViewObject (IShellFolder2 * iface,
326 HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
327 {
328 ICOM_THIS (IGenericSFImpl, iface);
329
330 LPSHELLVIEW pShellView;
331 HRESULT hr = E_INVALIDARG;
332
333 TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid (riid), ppvOut);
334
335 if (ppvOut) {
336 *ppvOut = NULL;
337
338 if (IsEqualIID (riid, &IID_IDropTarget)) {
339 WARN ("IDropTarget not implemented\n");
340 hr = E_NOTIMPL;
341 } else if (IsEqualIID (riid, &IID_IContextMenu)) {
342 WARN ("IContextMenu not implemented\n");
343 hr = E_NOTIMPL;
344 } else if (IsEqualIID (riid, &IID_IShellView)) {
345 pShellView = IShellView_Constructor ((IShellFolder *) iface);
346 if (pShellView) {
347 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
348 IShellView_Release (pShellView);
349 }
350 }
351 }
352 TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut);
353 return hr;
354 }
355
356 /**************************************************************************
357 * ISF_Desktop_fnGetAttributesOf
358 */
359 static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf (IShellFolder2 * iface,
360 UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
361 {
362 ICOM_THIS (IGenericSFImpl, iface);
363
364 HRESULT hr = S_OK;
365
366 TRACE ("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", This, cidl, apidl, *rgfInOut);
367
368 if ((!cidl) || (!apidl) || (!rgfInOut))
369 return E_INVALIDARG;
370
371 while (cidl > 0 && *apidl) {
372 pdump (*apidl);
373 SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut);
374 apidl++;
375 cidl--;
376 }
377
378 TRACE ("-- result=0x%08lx\n", *rgfInOut);
379
380 return hr;
381 }
382
383 /**************************************************************************
384 * ISF_Desktop_fnGetUIObjectOf
385 *
386 * PARAMETERS
387 * HWND hwndOwner, //[in ] Parent window for any output
388 * UINT cidl, //[in ] array size
389 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
390 * REFIID riid, //[in ] Requested Interface
391 * UINT* prgfInOut, //[ ] reserved
392 * LPVOID* ppvObject) //[out] Resulting Interface
393 *
394 */
395 static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface,
396 HWND hwndOwner,
397 UINT cidl,
398 LPCITEMIDLIST * apidl,
399 REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
400 {
401 ICOM_THIS (IGenericSFImpl, iface);
402
403 LPITEMIDLIST pidl;
404 IUnknown *pObj = NULL;
405 HRESULT hr = E_INVALIDARG;
406
407 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
408 This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
409
410 if (ppvOut) {
411 *ppvOut = NULL;
412
413 if (IsEqualIID (riid, &IID_IContextMenu)) {
414 pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
415 hr = S_OK;
416 } else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) {
417 pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl);
418 hr = S_OK;
419 } else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) {
420 pidl = ILCombine (This->pidlRoot, apidl[0]);
421 pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
422 SHFree (pidl);
423 hr = S_OK;
424 } else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) {
425 pidl = ILCombine (This->pidlRoot, apidl[0]);
426 pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
427 SHFree (pidl);
428 hr = S_OK;
429 } else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) {
430 hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj);
431 } else if ((IsEqualIID(riid,&IID_IShellLinkW) || IsEqualIID(riid,&IID_IShellLinkA))
432 && (cidl == 1)) {
433 pidl = ILCombine (This->pidlRoot, apidl[0]);
434 hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj);
435 SHFree (pidl);
436 } else {
437 hr = E_NOINTERFACE;
438 }
439
440 if (SUCCEEDED(hr) && !pObj)
441 hr = E_OUTOFMEMORY;
442
443 *ppvOut = pObj;
444 }
445 TRACE ("(%p)->hr=0x%08lx\n", This, hr);
446 return hr;
447 }
448
449 /**************************************************************************
450 * ISF_Desktop_fnGetDisplayNameOf
451 *
452 * NOTES
453 * special case: pidl = null gives desktop-name back
454 */
455 static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
456 LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
457 {
458 ICOM_THIS (IGenericSFImpl, iface);
459
460 CHAR szPath[MAX_PATH];
461 GUID const *clsid;
462 HRESULT hr = S_OK;
463
464 *szPath = '\0';
465
466 TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet);
467 pdump (pidl);
468
469 if (!strRet)
470 return E_INVALIDARG;
471
472 if (_ILIsDesktop (pidl)) {
473 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING)) {
474 lstrcpyA (szPath, This->sPathTarget);
475 } else {
476 HCR_GetClassNameA(&CLSID_ShellDesktop, szPath, MAX_PATH);
477 }
478 } else if (_ILIsPidlSimple (pidl)) {
479 if ((clsid = _ILGetGUIDPointer (pidl))) {
480 if (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING) {
481 int bWantsForParsing;
482
483 /*
484 * we can only get a filesystem path from a shellfolder if the value WantsFORPARSING in
485 * CLSID\\{...}\\shellfolder exists
486 * exception: the MyComputer folder has this keys not but like any filesystem backed
487 * folder it needs these behaviour
488 */
489 if (IsEqualIID (clsid, &CLSID_MyComputer)) {
490 bWantsForParsing = 1;
491 } else {
492 /* get the "WantsFORPARSING" flag from the registry */
493 char szRegPath[100];
494
495 lstrcpyA (szRegPath, "CLSID\\");
496 SHELL32_GUIDToStringA (clsid, &szRegPath[6]);
497 lstrcatA (szRegPath, "\\shellfolder");
498 bWantsForParsing =
499 (ERROR_SUCCESS ==
500 SHGetValueA (HKEY_CLASSES_ROOT, szRegPath, "WantsFORPARSING", NULL, NULL, NULL));
501 }
502
503 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && bWantsForParsing) {
504 /* we need the filesystem path to the destination folder. Only the folder itself can know it */
505 hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH);
506 } else {
507 /* parsing name like ::{...} */
508 lstrcpyA (szPath, "::");
509 SHELL32_GUIDToStringA (clsid, &szPath[2]);
510 }
511 } else {
512 /* user friendly name */
513 HCR_GetClassNameA (clsid, szPath, MAX_PATH);
514 }
515 } else {
516 /* file system folder */
517 _ILSimpleGetText (pidl, szPath, MAX_PATH);
518
519 if (!_ILIsFolder(pidl))
520 SHELL_FS_ProcessDisplayFilename(szPath, dwFlags);
521 }
522 } else {
523 /* a complex pidl, let the subfolder do the work */
524 hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH);
525 }
526
527 if (SUCCEEDED (hr)) {
528 strRet->uType = STRRET_CSTR;
529 lstrcpynA (strRet->u.cStr, szPath, MAX_PATH);
530 }
531
532 TRACE ("-- (%p)->(%s,0x%08lx)\n", This, szPath, hr);
533 return hr;
534 }
535
536 /**************************************************************************
537 * ISF_Desktop_fnSetNameOf
538 * Changes the name of a file object or subfolder, possibly changing its item
539 * identifier in the process.
540 *
541 * PARAMETERS
542 * HWND hwndOwner, //[in ] Owner window for output
543 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
544 * LPCOLESTR lpszName, //[in ] the items new display name
545 * DWORD dwFlags, //[in ] SHGNO formatting flags
546 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
547 */
548 static HRESULT WINAPI ISF_Desktop_fnSetNameOf (IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */
549 LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
550 {
551 ICOM_THIS (IGenericSFImpl, iface);
552
553 FIXME ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
554
555 return E_FAIL;
556 }
557
558 static HRESULT WINAPI ISF_Desktop_fnGetDefaultSearchGUID (IShellFolder2 * iface, GUID * pguid)
559 {
560 ICOM_THIS (IGenericSFImpl, iface);
561
562 FIXME ("(%p)\n", This);
563 return E_NOTIMPL;
564 }
565 static HRESULT WINAPI ISF_Desktop_fnEnumSearches (IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
566 {
567 ICOM_THIS (IGenericSFImpl, iface);
568 FIXME ("(%p)\n", This);
569 return E_NOTIMPL;
570 }
571 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumn (IShellFolder2 * iface,
572 DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
573 {
574 ICOM_THIS (IGenericSFImpl, iface);
575
576 TRACE ("(%p)\n", This);
577
578 if (pSort)
579 *pSort = 0;
580 if (pDisplay)
581 *pDisplay = 0;
582
583 return S_OK;
584 }
585 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
586 {
587 ICOM_THIS (IGenericSFImpl, iface);
588
589 TRACE ("(%p)\n", This);
590
591 if (!pcsFlags || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
592 return E_INVALIDARG;
593
594 *pcsFlags = DesktopSFHeader[iColumn].pcsFlags;
595
596 return S_OK;
597 }
598 static HRESULT WINAPI ISF_Desktop_fnGetDetailsEx (IShellFolder2 * iface,
599 LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
600 {
601 ICOM_THIS (IGenericSFImpl, iface);
602 FIXME ("(%p)\n", This);
603
604 return E_NOTIMPL;
605 }
606 static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface,
607 LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
608 {
609 ICOM_THIS (IGenericSFImpl, iface);
610
611 HRESULT hr = E_FAIL;
612
613 TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
614
615 if (!psd || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
616 return E_INVALIDARG;
617
618 if (!pidl) {
619 psd->fmt = DesktopSFHeader[iColumn].fmt;
620 psd->cxChar = DesktopSFHeader[iColumn].cxChar;
621 psd->str.uType = STRRET_CSTR;
622 LoadStringA (shell32_hInstance, DesktopSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
623 return S_OK;
624 } else {
625 /* the data from the pidl */
626 switch (iColumn) {
627 case 0: /* name */
628 hr = IShellFolder_GetDisplayNameOf (iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
629 break;
630 case 1: /* size */
631 _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH);
632 break;
633 case 2: /* type */
634 _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
635 break;
636 case 3: /* date */
637 _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH);
638 break;
639 case 4: /* attributes */
640 _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH);
641 break;
642 }
643 hr = S_OK;
644 psd->str.uType = STRRET_CSTR;
645 }
646
647 return hr;
648 }
649 static HRESULT WINAPI ISF_Desktop_fnMapColumnToSCID (IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
650 {
651 ICOM_THIS (IGenericSFImpl, iface);
652 FIXME ("(%p)\n", This);
653 return E_NOTIMPL;
654 }
655
656 static ICOM_VTABLE (IShellFolder2) vt_MCFldr_ShellFolder2 =
657 {
658 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
659 ISF_Desktop_fnQueryInterface,
660 ISF_Desktop_fnAddRef,
661 ISF_Desktop_fnRelease,
662 ISF_Desktop_fnParseDisplayName,
663 ISF_Desktop_fnEnumObjects,
664 ISF_Desktop_fnBindToObject,
665 ISF_Desktop_fnBindToStorage,
666 ISF_Desktop_fnCompareIDs,
667 ISF_Desktop_fnCreateViewObject,
668 ISF_Desktop_fnGetAttributesOf,
669 ISF_Desktop_fnGetUIObjectOf,
670 ISF_Desktop_fnGetDisplayNameOf,
671 ISF_Desktop_fnSetNameOf,
672 /* ShellFolder2 */
673 ISF_Desktop_fnGetDefaultSearchGUID,
674 ISF_Desktop_fnEnumSearches,
675 ISF_Desktop_fnGetDefaultColumn,
676 ISF_Desktop_fnGetDefaultColumnState,
677 ISF_Desktop_fnGetDetailsEx,
678 ISF_Desktop_fnGetDetailsOf,
679 ISF_Desktop_fnMapColumnToSCID
680 };