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