3 * Virtual Desktop Folder
5 * Copyright 1997 Marcus Meissner
6 * Copyright 1998, 1999, 2002 Juergen Schmied
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/port.h"
32 #define NONAMELESSUNION
33 #define NONAMELESSSTRUCT
45 #include "enumidlist.h"
47 #include "undocshell.h"
48 #include "shell32_main.h"
51 #include "shellfolder.h"
52 #include "wine/debug.h"
56 WINE_DEFAULT_DEBUG_CHANNEL (shell
);
58 /***********************************************************************
59 * Desktopfolder implementation
63 const IShellFolder2Vtbl
*lpVtbl
;
64 const IPersistFolder2Vtbl
*lpPF2
;
67 /* both paths are parsible from the desktop */
68 LPWSTR sPathTarget
; /* complete path to target used for enumeration and ChangeNotify */
69 LPITEMIDLIST pidlRoot
; /* absolute pidl */
71 UINT cfShellIDList
; /* clipboardformat for IDropTarget */
72 BOOL fAcceptFmt
; /* flag for pending Drop */
75 #define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl)
76 #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
78 static const shvheader DesktopSFHeader
[] = {
79 {IDS_SHV_COLUMN1
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 15},
80 {IDS_SHV_COLUMN2
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
81 {IDS_SHV_COLUMN3
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
82 {IDS_SHV_COLUMN4
, SHCOLSTATE_TYPE_DATE
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 12},
83 {IDS_SHV_COLUMN5
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 5}
86 #define DESKTOPSHELLVIEWCOLUMNS 5
88 /**************************************************************************
89 * ISF_Desktop_fnQueryInterface
91 * NOTES supports not IPersist/IPersistFolder
93 static HRESULT WINAPI
ISF_Desktop_fnQueryInterface(
94 IShellFolder2
* iface
, REFIID riid
, LPVOID
* ppvObj
)
96 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
98 TRACE ("(%p)->(%s,%p)\n", This
, shdebugstr_guid (riid
), ppvObj
);
102 if (IsEqualIID (riid
, &IID_IUnknown
) ||
103 IsEqualIID (riid
, &IID_IShellFolder
) ||
104 IsEqualIID (riid
, &IID_IShellFolder2
))
108 else if (IsEqualIID (riid
, &IID_IPersistFolder
) ||
109 IsEqualIID (riid
, &IID_IPersistFolder2
))
111 *ppvObj
= &This
->lpPF2
;
115 IUnknown_AddRef ((IUnknown
*) (*ppvObj
));
116 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj
, *ppvObj
);
119 TRACE ("-- Interface: E_NOINTERFACE\n");
120 return E_NOINTERFACE
;
123 static ULONG WINAPI
ISF_Desktop_fnAddRef (IShellFolder2
* iface
)
125 return 2; /* non-heap based object */
128 static ULONG WINAPI
ISF_Desktop_fnRelease (IShellFolder2
* iface
)
130 return 1; /* non-heap based object */
133 /**************************************************************************
134 * ISF_Desktop_fnParseDisplayName
137 * "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds
140 static HRESULT WINAPI
ISF_Desktop_fnParseDisplayName (IShellFolder2
* iface
,
141 HWND hwndOwner
, LPBC pbc
, LPOLESTR lpszDisplayName
,
142 DWORD
* pchEaten
, LPITEMIDLIST
* ppidl
, DWORD
* pdwAttributes
)
144 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
145 WCHAR szElement
[MAX_PATH
];
146 LPCWSTR szNext
= NULL
;
147 LPITEMIDLIST pidlTemp
= NULL
;
151 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
152 This
, hwndOwner
, pbc
, lpszDisplayName
, debugstr_w(lpszDisplayName
),
153 pchEaten
, ppidl
, pdwAttributes
);
155 if (!lpszDisplayName
|| !ppidl
)
161 *pchEaten
= 0; /* strange but like the original */
163 if (lpszDisplayName
[0] == ':' && lpszDisplayName
[1] == ':')
165 szNext
= GetNextElementW (lpszDisplayName
, szElement
, MAX_PATH
);
166 TRACE ("-- element: %s\n", debugstr_w (szElement
));
167 SHCLSIDFromStringW (szElement
+ 2, &clsid
);
168 pidlTemp
= _ILCreateGuid (PT_GUID
, &clsid
);
170 else if (PathGetDriveNumberW (lpszDisplayName
) >= 0)
172 /* it's a filesystem path with a drive. Let MyComputer/UnixDosFolder parse it */
174 if (UNIXFS_is_rooted_at_desktop())
175 pidlTemp
= _ILCreateGuid(PT_GUID
, &CLSID_UnixDosFolder
);
178 pidlTemp
= _ILCreateMyComputer ();
179 szNext
= lpszDisplayName
;
181 else if (PathIsUNCW(lpszDisplayName
))
183 pidlTemp
= _ILCreateNetwork();
184 szNext
= lpszDisplayName
;
186 else if( (pidlTemp
= SHELL32_CreatePidlFromBindCtx(pbc
, lpszDisplayName
)) )
193 /* it's a filesystem path on the desktop. Let a FSFolder parse it */
195 if (*lpszDisplayName
)
197 WCHAR szPath
[MAX_PATH
];
200 /* build a complete path to create a simple pidl */
201 lstrcpynW(szPath
, This
->sPathTarget
, MAX_PATH
);
202 pathPtr
= PathAddBackslashW(szPath
);
205 lstrcpynW(pathPtr
, lpszDisplayName
, MAX_PATH
- (pathPtr
- szPath
));
206 hr
= _ILCreateFromPathW(szPath
, &pidlTemp
);
210 /* should never reach here, but for completeness */
211 hr
= HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
);
215 pidlTemp
= _ILCreateMyComputer();
220 if (SUCCEEDED(hr
) && pidlTemp
)
222 if (szNext
&& *szNext
)
224 hr
= SHELL32_ParseNextElement(iface
, hwndOwner
, pbc
,
225 &pidlTemp
, (LPOLESTR
) szNext
, pchEaten
, pdwAttributes
);
229 if (pdwAttributes
&& *pdwAttributes
)
230 hr
= SHELL32_GetItemAttributes(_IShellFolder_ (This
),
231 pidlTemp
, pdwAttributes
);
237 TRACE ("(%p)->(-- ret=0x%08x)\n", This
, hr
);
242 /**************************************************************************
243 * CreateDesktopEnumList()
245 static const WCHAR Desktop_NameSpaceW
[] = { 'S','O','F','T','W','A','R','E',
246 '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
247 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l',
248 'o','r','e','r','\\','D','e','s','k','t','o','p','\\','N','a','m','e','s','p',
251 static BOOL
CreateDesktopEnumList(IEnumIDList
*list
, DWORD dwFlags
)
254 WCHAR szPath
[MAX_PATH
];
256 TRACE("(%p)->(flags=0x%08x)\n", list
, dwFlags
);
258 /* enumerate the root folders */
259 if (dwFlags
& SHCONTF_FOLDERS
)
264 /* create the pidl for This item */
265 ret
= AddToEnumList(list
, _ILCreateMyDocuments());
266 ret
= AddToEnumList(list
, _ILCreateMyComputer());
268 for (i
=0; i
<2; i
++) {
269 if (ret
&& !RegOpenKeyExW(i
== 0 ? HKEY_LOCAL_MACHINE
: HKEY_CURRENT_USER
,
270 Desktop_NameSpaceW
, 0, KEY_READ
, &hkey
))
282 r
= RegEnumKeyExW(hkey
, i
, iid
, &size
, 0, NULL
, NULL
, NULL
);
283 if (ERROR_SUCCESS
== r
)
285 pidl
= _ILCreateGuidFromStrW(iid
);
286 if (_ILIsMyDocuments(pidl
))
292 ret
= AddToEnumList(list
, _ILCreateGuidFromStrW(iid
));
296 else if (ERROR_NO_MORE_ITEMS
== r
)
306 /* enumerate the elements in %windir%\desktop */
307 SHGetSpecialFolderPathW(0, szPath
, CSIDL_DESKTOPDIRECTORY
, FALSE
);
308 ret
= ret
&& CreateFolderEnumList(list
, szPath
, dwFlags
);
313 /**************************************************************************
314 * ISF_Desktop_fnEnumObjects
316 static HRESULT WINAPI
ISF_Desktop_fnEnumObjects (IShellFolder2
* iface
,
317 HWND hwndOwner
, DWORD dwFlags
, LPENUMIDLIST
* ppEnumIDList
)
319 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
321 TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n",
322 This
, hwndOwner
, dwFlags
, ppEnumIDList
);
324 *ppEnumIDList
= IEnumIDList_Constructor();
326 CreateDesktopEnumList(*ppEnumIDList
, dwFlags
);
328 TRACE ("-- (%p)->(new ID List: %p)\n", This
, *ppEnumIDList
);
330 return *ppEnumIDList
? S_OK
: E_OUTOFMEMORY
;
333 /**************************************************************************
334 * ISF_Desktop_fnBindToObject
336 static HRESULT WINAPI
ISF_Desktop_fnBindToObject (IShellFolder2
* iface
,
337 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
339 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
341 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n",
342 This
, pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
344 return SHELL32_BindToChild( This
->pidlRoot
, This
->sPathTarget
, pidl
, riid
, ppvOut
);
347 /**************************************************************************
348 * ISF_Desktop_fnBindToStorage
350 static HRESULT WINAPI
ISF_Desktop_fnBindToStorage (IShellFolder2
* iface
,
351 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
353 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
355 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n",
356 This
, pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
362 /**************************************************************************
363 * ISF_Desktop_fnCompareIDs
365 static HRESULT WINAPI
ISF_Desktop_fnCompareIDs (IShellFolder2
* iface
,
366 LPARAM lParam
, LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
368 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
371 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This
, lParam
, pidl1
, pidl2
);
372 nReturn
= SHELL32_CompareIDs (_IShellFolder_ (This
), lParam
, pidl1
, pidl2
);
373 TRACE ("-- %i\n", nReturn
);
377 /**************************************************************************
378 * ISF_Desktop_fnCreateViewObject
380 static HRESULT WINAPI
ISF_Desktop_fnCreateViewObject (IShellFolder2
* iface
,
381 HWND hwndOwner
, REFIID riid
, LPVOID
* ppvOut
)
383 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
384 LPSHELLVIEW pShellView
;
385 HRESULT hr
= E_INVALIDARG
;
387 TRACE ("(%p)->(hwnd=%p,%s,%p)\n",
388 This
, hwndOwner
, shdebugstr_guid (riid
), ppvOut
);
395 if (IsEqualIID (riid
, &IID_IDropTarget
))
397 WARN ("IDropTarget not implemented\n");
400 else if (IsEqualIID (riid
, &IID_IContextMenu
))
402 WARN ("IContextMenu not implemented\n");
405 else if (IsEqualIID (riid
, &IID_IShellView
))
407 pShellView
= IShellView_Constructor ((IShellFolder
*) iface
);
410 hr
= IShellView_QueryInterface (pShellView
, riid
, ppvOut
);
411 IShellView_Release (pShellView
);
414 TRACE ("-- (%p)->(interface=%p)\n", This
, ppvOut
);
418 /**************************************************************************
419 * ISF_Desktop_fnGetAttributesOf
421 static HRESULT WINAPI
ISF_Desktop_fnGetAttributesOf (IShellFolder2
* iface
,
422 UINT cidl
, LPCITEMIDLIST
* apidl
, DWORD
* rgfInOut
)
424 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
426 static const DWORD dwDesktopAttributes
=
427 SFGAO_STORAGE
| SFGAO_HASPROPSHEET
| SFGAO_STORAGEANCESTOR
|
428 SFGAO_FILESYSANCESTOR
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_HASSUBFOLDER
;
429 static const DWORD dwMyComputerAttributes
=
430 SFGAO_CANRENAME
| SFGAO_CANDELETE
| SFGAO_HASPROPSHEET
|
431 SFGAO_DROPTARGET
| SFGAO_FILESYSANCESTOR
| SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
;
433 TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
434 This
, cidl
, apidl
, rgfInOut
, rgfInOut
? *rgfInOut
: 0);
445 *rgfInOut
&= dwDesktopAttributes
;
447 while (cidl
> 0 && *apidl
) {
449 if (_ILIsDesktop(*apidl
)) {
450 *rgfInOut
&= dwDesktopAttributes
;
451 } else if (_ILIsMyComputer(*apidl
)) {
452 *rgfInOut
&= dwMyComputerAttributes
;
454 SHELL32_GetItemAttributes (_IShellFolder_ (This
), *apidl
, rgfInOut
);
460 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
461 *rgfInOut
&= ~SFGAO_VALIDATE
;
463 TRACE ("-- result=0x%08x\n", *rgfInOut
);
468 /**************************************************************************
469 * ISF_Desktop_fnGetUIObjectOf
472 * HWND hwndOwner, //[in ] Parent window for any output
473 * UINT cidl, //[in ] array size
474 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
475 * REFIID riid, //[in ] Requested Interface
476 * UINT* prgfInOut, //[ ] reserved
477 * LPVOID* ppvObject) //[out] Resulting Interface
480 static HRESULT WINAPI
ISF_Desktop_fnGetUIObjectOf (IShellFolder2
* iface
,
481 HWND hwndOwner
, UINT cidl
, LPCITEMIDLIST
* apidl
,
482 REFIID riid
, UINT
* prgfInOut
, LPVOID
* ppvOut
)
484 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
487 IUnknown
*pObj
= NULL
;
488 HRESULT hr
= E_INVALIDARG
;
490 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
491 This
, hwndOwner
, cidl
, apidl
, shdebugstr_guid (riid
), prgfInOut
, ppvOut
);
498 if (IsEqualIID (riid
, &IID_IContextMenu
))
500 hr
= CDefFolderMenu_Create2(This
->pidlRoot
, hwndOwner
, cidl
, apidl
, (IShellFolder
*)iface
, NULL
, 0, NULL
, (IContextMenu
**)&pObj
);
502 else if (IsEqualIID (riid
, &IID_IDataObject
) && (cidl
>= 1))
504 pObj
= (LPUNKNOWN
) IDataObject_Constructor( hwndOwner
,
505 This
->pidlRoot
, apidl
, cidl
);
508 else if (IsEqualIID (riid
, &IID_IExtractIconA
) && (cidl
== 1))
510 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
511 pObj
= (LPUNKNOWN
) IExtractIconA_Constructor (pidl
);
515 else if (IsEqualIID (riid
, &IID_IExtractIconW
) && (cidl
== 1))
517 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
518 pObj
= (LPUNKNOWN
) IExtractIconW_Constructor (pidl
);
522 else if (IsEqualIID (riid
, &IID_IDropTarget
) && (cidl
>= 1))
524 hr
= IShellFolder_QueryInterface (iface
,
525 &IID_IDropTarget
, (LPVOID
*) & pObj
);
527 else if ((IsEqualIID(riid
,&IID_IShellLinkW
) ||
528 IsEqualIID(riid
,&IID_IShellLinkA
)) && (cidl
== 1))
530 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
531 hr
= IShellLink_ConstructFromFile(NULL
, riid
, pidl
, (LPVOID
*)&pObj
);
537 if (SUCCEEDED(hr
) && !pObj
)
541 TRACE ("(%p)->hr=0x%08x\n", This
, hr
);
545 /**************************************************************************
546 * ISF_Desktop_fnGetDisplayNameOf
549 * special case: pidl = null gives desktop-name back
551 static HRESULT WINAPI
ISF_Desktop_fnGetDisplayNameOf (IShellFolder2
* iface
,
552 LPCITEMIDLIST pidl
, DWORD dwFlags
, LPSTRRET strRet
)
554 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
558 TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This
, pidl
, dwFlags
, strRet
);
564 pszPath
= CoTaskMemAlloc((MAX_PATH
+1) * sizeof(WCHAR
));
566 return E_OUTOFMEMORY
;
568 if (_ILIsDesktop (pidl
))
570 if ((GET_SHGDN_RELATION (dwFlags
) == SHGDN_NORMAL
) &&
571 (GET_SHGDN_FOR (dwFlags
) & SHGDN_FORPARSING
))
572 strcpyW(pszPath
, This
->sPathTarget
);
574 HCR_GetClassNameW(&CLSID_ShellDesktop
, pszPath
, MAX_PATH
);
576 else if (_ILIsPidlSimple (pidl
))
580 if ((clsid
= _ILGetGUIDPointer (pidl
)))
582 if (GET_SHGDN_FOR (dwFlags
) & SHGDN_FORPARSING
)
584 int bWantsForParsing
;
587 * We can only get a filesystem path from a shellfolder if the
588 * value WantsFORPARSING in CLSID\\{...}\\shellfolder exists.
590 * Exception: The MyComputer folder doesn't have this key,
591 * but any other filesystem backed folder it needs it.
593 if (IsEqualIID (clsid
, &CLSID_MyComputer
))
595 bWantsForParsing
= TRUE
;
599 /* get the "WantsFORPARSING" flag from the registry */
600 static const WCHAR clsidW
[] =
601 { 'C','L','S','I','D','\\',0 };
602 static const WCHAR shellfolderW
[] =
603 { '\\','s','h','e','l','l','f','o','l','d','e','r',0 };
604 static const WCHAR wantsForParsingW
[] =
605 { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n',
607 WCHAR szRegPath
[100];
610 lstrcpyW (szRegPath
, clsidW
);
611 SHELL32_GUIDToStringW (clsid
, &szRegPath
[6]);
612 lstrcatW (szRegPath
, shellfolderW
);
613 r
= SHGetValueW(HKEY_CLASSES_ROOT
, szRegPath
,
614 wantsForParsingW
, NULL
, NULL
, NULL
);
615 if (r
== ERROR_SUCCESS
)
616 bWantsForParsing
= TRUE
;
618 bWantsForParsing
= FALSE
;
621 if ((GET_SHGDN_RELATION (dwFlags
) == SHGDN_NORMAL
) &&
625 * we need the filesystem path to the destination folder.
626 * Only the folder itself can know it
628 hr
= SHELL32_GetDisplayNameOfChild (iface
, pidl
, dwFlags
,
634 /* parsing name like ::{...} */
637 SHELL32_GUIDToStringW (clsid
, &pszPath
[2]);
642 /* user friendly name */
643 HCR_GetClassNameW (clsid
, pszPath
, MAX_PATH
);
650 /* file system folder or file rooted at the desktop */
651 if ((GET_SHGDN_FOR(dwFlags
) == SHGDN_FORPARSING
) &&
652 (GET_SHGDN_RELATION(dwFlags
) != SHGDN_INFOLDER
))
654 lstrcpynW(pszPath
, This
->sPathTarget
, MAX_PATH
- 1);
655 PathAddBackslashW(pszPath
);
656 cLen
= lstrlenW(pszPath
);
659 _ILSimpleGetTextW(pidl
, pszPath
+ cLen
, MAX_PATH
- cLen
);
661 if (!_ILIsFolder(pidl
))
662 SHELL_FS_ProcessDisplayFilename(pszPath
, dwFlags
);
667 /* a complex pidl, let the subfolder do the work */
668 hr
= SHELL32_GetDisplayNameOfChild (iface
, pidl
, dwFlags
,
674 /* Win9x always returns ANSI strings, NT always returns Unicode strings */
675 if (GetVersion() & 0x80000000)
677 strRet
->uType
= STRRET_CSTR
;
678 if (!WideCharToMultiByte(CP_ACP
, 0, pszPath
, -1, strRet
->u
.cStr
, MAX_PATH
,
680 strRet
->u
.cStr
[0] = '\0';
681 CoTaskMemFree(pszPath
);
685 strRet
->uType
= STRRET_WSTR
;
686 strRet
->u
.pOleStr
= pszPath
;
690 CoTaskMemFree(pszPath
);
692 TRACE ("-- (%p)->(%s,0x%08x)\n", This
,
693 strRet
->uType
== STRRET_CSTR
? strRet
->u
.cStr
:
694 debugstr_w(strRet
->u
.pOleStr
), hr
);
698 /**************************************************************************
699 * ISF_Desktop_fnSetNameOf
700 * Changes the name of a file object or subfolder, possibly changing its item
701 * identifier in the process.
704 * HWND hwndOwner, //[in ] Owner window for output
705 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
706 * LPCOLESTR lpszName, //[in ] the items new display name
707 * DWORD dwFlags, //[in ] SHGNO formatting flags
708 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
710 static HRESULT WINAPI
ISF_Desktop_fnSetNameOf (IShellFolder2
* iface
,
711 HWND hwndOwner
, LPCITEMIDLIST pidl
, /* simple pidl */
712 LPCOLESTR lpName
, DWORD dwFlags
, LPITEMIDLIST
* pPidlOut
)
714 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
716 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This
, hwndOwner
, pidl
,
717 debugstr_w (lpName
), dwFlags
, pPidlOut
);
722 static HRESULT WINAPI
ISF_Desktop_fnGetDefaultSearchGUID(IShellFolder2
*iface
,
725 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
727 FIXME ("(%p)\n", This
);
731 static HRESULT WINAPI
ISF_Desktop_fnEnumSearches (IShellFolder2
*iface
,
732 IEnumExtraSearch
** ppenum
)
734 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
735 FIXME ("(%p)\n", This
);
739 static HRESULT WINAPI
ISF_Desktop_fnGetDefaultColumn (IShellFolder2
* iface
,
740 DWORD dwRes
, ULONG
* pSort
, ULONG
* pDisplay
)
742 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
744 TRACE ("(%p)\n", This
);
753 static HRESULT WINAPI
ISF_Desktop_fnGetDefaultColumnState (
754 IShellFolder2
* iface
, UINT iColumn
, DWORD
* pcsFlags
)
756 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
758 TRACE ("(%p)\n", This
);
760 if (!pcsFlags
|| iColumn
>= DESKTOPSHELLVIEWCOLUMNS
)
763 *pcsFlags
= DesktopSFHeader
[iColumn
].pcsFlags
;
768 static HRESULT WINAPI
ISF_Desktop_fnGetDetailsEx (IShellFolder2
* iface
,
769 LPCITEMIDLIST pidl
, const SHCOLUMNID
* pscid
, VARIANT
* pv
)
771 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
772 FIXME ("(%p)\n", This
);
777 static HRESULT WINAPI
ISF_Desktop_fnGetDetailsOf (IShellFolder2
* iface
,
778 LPCITEMIDLIST pidl
, UINT iColumn
, SHELLDETAILS
* psd
)
780 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
784 TRACE ("(%p)->(%p %i %p)\n", This
, pidl
, iColumn
, psd
);
786 if (!psd
|| iColumn
>= DESKTOPSHELLVIEWCOLUMNS
)
791 psd
->fmt
= DesktopSFHeader
[iColumn
].fmt
;
792 psd
->cxChar
= DesktopSFHeader
[iColumn
].cxChar
;
793 psd
->str
.uType
= STRRET_CSTR
;
794 LoadStringA (shell32_hInstance
, DesktopSFHeader
[iColumn
].colnameid
,
795 psd
->str
.u
.cStr
, MAX_PATH
);
799 /* the data from the pidl */
800 psd
->str
.uType
= STRRET_CSTR
;
804 hr
= IShellFolder_GetDisplayNameOf(iface
, pidl
,
805 SHGDN_NORMAL
| SHGDN_INFOLDER
, &psd
->str
);
808 _ILGetFileSize (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
811 _ILGetFileType (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
814 _ILGetFileDate (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
816 case 4: /* attributes */
817 _ILGetFileAttributes (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
824 static HRESULT WINAPI
ISF_Desktop_fnMapColumnToSCID (
825 IShellFolder2
* iface
, UINT column
, SHCOLUMNID
* pscid
)
827 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
828 FIXME ("(%p)\n", This
);
832 static const IShellFolder2Vtbl vt_MCFldr_ShellFolder2
=
834 ISF_Desktop_fnQueryInterface
,
835 ISF_Desktop_fnAddRef
,
836 ISF_Desktop_fnRelease
,
837 ISF_Desktop_fnParseDisplayName
,
838 ISF_Desktop_fnEnumObjects
,
839 ISF_Desktop_fnBindToObject
,
840 ISF_Desktop_fnBindToStorage
,
841 ISF_Desktop_fnCompareIDs
,
842 ISF_Desktop_fnCreateViewObject
,
843 ISF_Desktop_fnGetAttributesOf
,
844 ISF_Desktop_fnGetUIObjectOf
,
845 ISF_Desktop_fnGetDisplayNameOf
,
846 ISF_Desktop_fnSetNameOf
,
848 ISF_Desktop_fnGetDefaultSearchGUID
,
849 ISF_Desktop_fnEnumSearches
,
850 ISF_Desktop_fnGetDefaultColumn
,
851 ISF_Desktop_fnGetDefaultColumnState
,
852 ISF_Desktop_fnGetDetailsEx
,
853 ISF_Desktop_fnGetDetailsOf
,
854 ISF_Desktop_fnMapColumnToSCID
857 static inline IGenericSFImpl
*impl_from_IPersistFolder2( IPersistFolder2
*iface
)
859 return (IGenericSFImpl
*)((char*)iface
- FIELD_OFFSET(IGenericSFImpl
, lpPF2
));
862 static HRESULT WINAPI
863 ISF_Desktop_PersistFolder2_fnQueryInterface (IPersistFolder2
* iface
, REFIID iid
,
866 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
868 TRACE ("(%p)\n", This
);
870 return ISF_Desktop_fnQueryInterface ((IShellFolder2
*)This
, iid
, ppvObj
);
874 ISF_Desktop_PersistFolder2_fnAddRef (IPersistFolder2
* iface
)
876 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
878 TRACE ("(%p)->(count=%u)\n", This
, This
->ref
);
880 return ISF_Desktop_fnAddRef((IShellFolder2
*)This
);
884 ISF_Desktop_PersistFolder2_fnRelease (IPersistFolder2
* iface
)
886 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
888 TRACE ("(%p)->(count=%u)\n", This
, This
->ref
);
890 return ISF_Desktop_fnRelease ((IShellFolder2
*)This
);
893 static HRESULT WINAPI
894 ISF_Desktop_PersistFolder2_fnGetClassID (IPersistFolder2
* iface
, CLSID
* lpClassId
)
896 static GUID
const CLSID_Desktop
=
897 { 0x00021400, 0x0000, 0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46} };
899 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
901 TRACE ("(%p)\n", This
);
906 memcpy(lpClassId
, &CLSID_Desktop
, sizeof(GUID
));
910 static HRESULT WINAPI
911 ISF_Desktop_PersistFolder2_fnInitialize (IPersistFolder2
* iface
, LPCITEMIDLIST pidl
)
913 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
915 TRACE ("(%p)->(%p)\n", This
, pidl
);
920 static HRESULT WINAPI
921 ISF_Desktop_PersistFolder2_fnGetCurFolder (IPersistFolder2
* iface
,
924 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
926 TRACE ("(%p)->(%p)\n", This
, pidl
);
928 if (!pidl
) return E_POINTER
;
929 *pidl
= ILClone (This
->pidlRoot
);
933 static const IPersistFolder2Vtbl vt_FSFldr_PersistFolder2
=
935 ISF_Desktop_PersistFolder2_fnQueryInterface
,
936 ISF_Desktop_PersistFolder2_fnAddRef
,
937 ISF_Desktop_PersistFolder2_fnRelease
,
938 ISF_Desktop_PersistFolder2_fnGetClassID
,
939 ISF_Desktop_PersistFolder2_fnInitialize
,
940 ISF_Desktop_PersistFolder2_fnGetCurFolder
,
944 /**************************************************************************
945 * ISF_Desktop_Constructor
947 HRESULT WINAPI
ISF_Desktop_Constructor (
948 IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
950 static IGenericSFImpl
*cached_sf
;
951 WCHAR szMyPath
[MAX_PATH
];
953 TRACE ("unkOut=%p %s\n", pUnkOuter
, shdebugstr_guid (riid
));
958 return CLASS_E_NOAGGREGATION
;
964 if (!SHGetSpecialFolderPathW( 0, szMyPath
, CSIDL_DESKTOPDIRECTORY
, TRUE
))
967 sf
= LocalAlloc( LMEM_ZEROINIT
, sizeof (IGenericSFImpl
) );
969 return E_OUTOFMEMORY
;
972 sf
->lpVtbl
= &vt_MCFldr_ShellFolder2
;
973 sf
->lpPF2
= &vt_FSFldr_PersistFolder2
;
974 sf
->pidlRoot
= _ILCreateDesktop(); /* my qualified pidl */
975 sf
->sPathTarget
= SHAlloc( (lstrlenW(szMyPath
) + 1)*sizeof(WCHAR
) );
976 lstrcpyW( sf
->sPathTarget
, szMyPath
);
978 if (InterlockedCompareExchangePointer((void *)&cached_sf
, sf
, NULL
) != NULL
)
980 /* some other thread already been here */
981 SHFree( sf
->pidlRoot
);
982 SHFree( sf
->sPathTarget
);
987 return IUnknown_QueryInterface( _IUnknown_(cached_sf
), riid
, ppv
);