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
, _ILCreateMyComputer());
267 for (i
=0; i
<2; i
++) {
268 if (ret
&& !RegOpenKeyExW(i
== 0 ? HKEY_LOCAL_MACHINE
: HKEY_CURRENT_USER
,
269 Desktop_NameSpaceW
, 0, KEY_READ
, &hkey
))
280 r
= RegEnumKeyExW(hkey
, i
, iid
, &size
, 0, NULL
, NULL
, NULL
);
281 if (ERROR_SUCCESS
== r
)
283 ret
= AddToEnumList(list
, _ILCreateGuidFromStrW(iid
));
286 else if (ERROR_NO_MORE_ITEMS
== r
)
296 /* enumerate the elements in %windir%\desktop */
297 SHGetSpecialFolderPathW(0, szPath
, CSIDL_DESKTOPDIRECTORY
, FALSE
);
298 ret
= ret
&& CreateFolderEnumList(list
, szPath
, dwFlags
);
303 /**************************************************************************
304 * ISF_Desktop_fnEnumObjects
306 static HRESULT WINAPI
ISF_Desktop_fnEnumObjects (IShellFolder2
* iface
,
307 HWND hwndOwner
, DWORD dwFlags
, LPENUMIDLIST
* ppEnumIDList
)
309 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
311 TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n",
312 This
, hwndOwner
, dwFlags
, ppEnumIDList
);
314 *ppEnumIDList
= IEnumIDList_Constructor();
316 CreateDesktopEnumList(*ppEnumIDList
, dwFlags
);
318 TRACE ("-- (%p)->(new ID List: %p)\n", This
, *ppEnumIDList
);
320 return *ppEnumIDList
? S_OK
: E_OUTOFMEMORY
;
323 /**************************************************************************
324 * ISF_Desktop_fnBindToObject
326 static HRESULT WINAPI
ISF_Desktop_fnBindToObject (IShellFolder2
* iface
,
327 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
329 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
331 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n",
332 This
, pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
334 return SHELL32_BindToChild( This
->pidlRoot
, This
->sPathTarget
, pidl
, riid
, ppvOut
);
337 /**************************************************************************
338 * ISF_Desktop_fnBindToStorage
340 static HRESULT WINAPI
ISF_Desktop_fnBindToStorage (IShellFolder2
* iface
,
341 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
343 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
345 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n",
346 This
, pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
352 /**************************************************************************
353 * ISF_Desktop_fnCompareIDs
355 static HRESULT WINAPI
ISF_Desktop_fnCompareIDs (IShellFolder2
* iface
,
356 LPARAM lParam
, LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
358 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
361 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This
, lParam
, pidl1
, pidl2
);
362 nReturn
= SHELL32_CompareIDs (_IShellFolder_ (This
), lParam
, pidl1
, pidl2
);
363 TRACE ("-- %i\n", nReturn
);
367 /**************************************************************************
368 * ISF_Desktop_fnCreateViewObject
370 static HRESULT WINAPI
ISF_Desktop_fnCreateViewObject (IShellFolder2
* iface
,
371 HWND hwndOwner
, REFIID riid
, LPVOID
* ppvOut
)
373 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
374 LPSHELLVIEW pShellView
;
375 HRESULT hr
= E_INVALIDARG
;
377 TRACE ("(%p)->(hwnd=%p,%s,%p)\n",
378 This
, hwndOwner
, shdebugstr_guid (riid
), ppvOut
);
385 if (IsEqualIID (riid
, &IID_IDropTarget
))
387 WARN ("IDropTarget not implemented\n");
390 else if (IsEqualIID (riid
, &IID_IContextMenu
))
392 WARN ("IContextMenu not implemented\n");
395 else if (IsEqualIID (riid
, &IID_IShellView
))
397 pShellView
= IShellView_Constructor ((IShellFolder
*) iface
);
400 hr
= IShellView_QueryInterface (pShellView
, riid
, ppvOut
);
401 IShellView_Release (pShellView
);
404 TRACE ("-- (%p)->(interface=%p)\n", This
, ppvOut
);
408 /**************************************************************************
409 * ISF_Desktop_fnGetAttributesOf
411 static HRESULT WINAPI
ISF_Desktop_fnGetAttributesOf (IShellFolder2
* iface
,
412 UINT cidl
, LPCITEMIDLIST
* apidl
, DWORD
* rgfInOut
)
414 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
416 static const DWORD dwDesktopAttributes
=
417 SFGAO_STORAGE
| SFGAO_HASPROPSHEET
| SFGAO_STORAGEANCESTOR
|
418 SFGAO_FILESYSANCESTOR
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_HASSUBFOLDER
;
419 static const DWORD dwMyComputerAttributes
=
420 SFGAO_CANRENAME
| SFGAO_CANDELETE
| SFGAO_HASPROPSHEET
|
421 SFGAO_DROPTARGET
| SFGAO_FILESYSANCESTOR
| SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
;
423 TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
424 This
, cidl
, apidl
, rgfInOut
, rgfInOut
? *rgfInOut
: 0);
435 *rgfInOut
&= dwDesktopAttributes
;
437 while (cidl
> 0 && *apidl
) {
439 if (_ILIsDesktop(*apidl
)) {
440 *rgfInOut
&= dwDesktopAttributes
;
441 } else if (_ILIsMyComputer(*apidl
)) {
442 *rgfInOut
&= dwMyComputerAttributes
;
444 SHELL32_GetItemAttributes (_IShellFolder_ (This
), *apidl
, rgfInOut
);
450 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
451 *rgfInOut
&= ~SFGAO_VALIDATE
;
453 TRACE ("-- result=0x%08x\n", *rgfInOut
);
458 /**************************************************************************
459 * ISF_Desktop_fnGetUIObjectOf
462 * HWND hwndOwner, //[in ] Parent window for any output
463 * UINT cidl, //[in ] array size
464 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
465 * REFIID riid, //[in ] Requested Interface
466 * UINT* prgfInOut, //[ ] reserved
467 * LPVOID* ppvObject) //[out] Resulting Interface
470 static HRESULT WINAPI
ISF_Desktop_fnGetUIObjectOf (IShellFolder2
* iface
,
471 HWND hwndOwner
, UINT cidl
, LPCITEMIDLIST
* apidl
,
472 REFIID riid
, UINT
* prgfInOut
, LPVOID
* ppvOut
)
474 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
477 IUnknown
*pObj
= NULL
;
478 HRESULT hr
= E_INVALIDARG
;
480 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
481 This
, hwndOwner
, cidl
, apidl
, shdebugstr_guid (riid
), prgfInOut
, ppvOut
);
488 if (IsEqualIID (riid
, &IID_IContextMenu
))
491 pObj
= (LPUNKNOWN
) ISvItemCm_Constructor( (IShellFolder
*) iface
, This
->pidlRoot
, apidl
, cidl
);
493 pObj
= (LPUNKNOWN
) ISvBgCm_Constructor( (IShellFolder
*) iface
, TRUE
);
496 else if (IsEqualIID (riid
, &IID_IDataObject
) && (cidl
>= 1))
498 pObj
= (LPUNKNOWN
) IDataObject_Constructor( hwndOwner
,
499 This
->pidlRoot
, apidl
, cidl
);
502 else if (IsEqualIID (riid
, &IID_IExtractIconA
) && (cidl
== 1))
504 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
505 pObj
= (LPUNKNOWN
) IExtractIconA_Constructor (pidl
);
509 else if (IsEqualIID (riid
, &IID_IExtractIconW
) && (cidl
== 1))
511 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
512 pObj
= (LPUNKNOWN
) IExtractIconW_Constructor (pidl
);
516 else if (IsEqualIID (riid
, &IID_IDropTarget
) && (cidl
>= 1))
518 hr
= IShellFolder_QueryInterface (iface
,
519 &IID_IDropTarget
, (LPVOID
*) & pObj
);
521 else if ((IsEqualIID(riid
,&IID_IShellLinkW
) ||
522 IsEqualIID(riid
,&IID_IShellLinkA
)) && (cidl
== 1))
524 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
525 hr
= IShellLink_ConstructFromFile(NULL
, riid
, pidl
, (LPVOID
*)&pObj
);
531 if (SUCCEEDED(hr
) && !pObj
)
535 TRACE ("(%p)->hr=0x%08x\n", This
, hr
);
539 /**************************************************************************
540 * ISF_Desktop_fnGetDisplayNameOf
543 * special case: pidl = null gives desktop-name back
545 static HRESULT WINAPI
ISF_Desktop_fnGetDisplayNameOf (IShellFolder2
* iface
,
546 LPCITEMIDLIST pidl
, DWORD dwFlags
, LPSTRRET strRet
)
548 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
552 TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This
, pidl
, dwFlags
, strRet
);
558 pszPath
= CoTaskMemAlloc((MAX_PATH
+1) * sizeof(WCHAR
));
560 return E_OUTOFMEMORY
;
562 if (_ILIsDesktop (pidl
))
564 if ((GET_SHGDN_RELATION (dwFlags
) == SHGDN_NORMAL
) &&
565 (GET_SHGDN_FOR (dwFlags
) & SHGDN_FORPARSING
))
566 strcpyW(pszPath
, This
->sPathTarget
);
568 HCR_GetClassNameW(&CLSID_ShellDesktop
, pszPath
, MAX_PATH
);
570 else if (_ILIsPidlSimple (pidl
))
574 if ((clsid
= _ILGetGUIDPointer (pidl
)))
576 if (GET_SHGDN_FOR (dwFlags
) & SHGDN_FORPARSING
)
578 int bWantsForParsing
;
581 * We can only get a filesystem path from a shellfolder if the
582 * value WantsFORPARSING in CLSID\\{...}\\shellfolder exists.
584 * Exception: The MyComputer folder doesn't have this key,
585 * but any other filesystem backed folder it needs it.
587 if (IsEqualIID (clsid
, &CLSID_MyComputer
))
589 bWantsForParsing
= TRUE
;
593 /* get the "WantsFORPARSING" flag from the registry */
594 static const WCHAR clsidW
[] =
595 { 'C','L','S','I','D','\\',0 };
596 static const WCHAR shellfolderW
[] =
597 { '\\','s','h','e','l','l','f','o','l','d','e','r',0 };
598 static const WCHAR wantsForParsingW
[] =
599 { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n',
601 WCHAR szRegPath
[100];
604 lstrcpyW (szRegPath
, clsidW
);
605 SHELL32_GUIDToStringW (clsid
, &szRegPath
[6]);
606 lstrcatW (szRegPath
, shellfolderW
);
607 r
= SHGetValueW(HKEY_CLASSES_ROOT
, szRegPath
,
608 wantsForParsingW
, NULL
, NULL
, NULL
);
609 if (r
== ERROR_SUCCESS
)
610 bWantsForParsing
= TRUE
;
612 bWantsForParsing
= FALSE
;
615 if ((GET_SHGDN_RELATION (dwFlags
) == SHGDN_NORMAL
) &&
619 * we need the filesystem path to the destination folder.
620 * Only the folder itself can know it
622 hr
= SHELL32_GetDisplayNameOfChild (iface
, pidl
, dwFlags
,
628 /* parsing name like ::{...} */
631 SHELL32_GUIDToStringW (clsid
, &pszPath
[2]);
636 /* user friendly name */
637 HCR_GetClassNameW (clsid
, pszPath
, MAX_PATH
);
644 /* file system folder or file rooted at the desktop */
645 if ((GET_SHGDN_FOR(dwFlags
) == SHGDN_FORPARSING
) &&
646 (GET_SHGDN_RELATION(dwFlags
) != SHGDN_INFOLDER
))
648 lstrcpynW(pszPath
, This
->sPathTarget
, MAX_PATH
- 1);
649 PathAddBackslashW(pszPath
);
650 cLen
= lstrlenW(pszPath
);
653 _ILSimpleGetTextW(pidl
, pszPath
+ cLen
, MAX_PATH
- cLen
);
655 if (!_ILIsFolder(pidl
))
656 SHELL_FS_ProcessDisplayFilename(pszPath
, dwFlags
);
661 /* a complex pidl, let the subfolder do the work */
662 hr
= SHELL32_GetDisplayNameOfChild (iface
, pidl
, dwFlags
,
668 /* Win9x always returns ANSI strings, NT always returns Unicode strings */
669 if (GetVersion() & 0x80000000)
671 strRet
->uType
= STRRET_CSTR
;
672 if (!WideCharToMultiByte(CP_ACP
, 0, pszPath
, -1, strRet
->u
.cStr
, MAX_PATH
,
674 strRet
->u
.cStr
[0] = '\0';
675 CoTaskMemFree(pszPath
);
679 strRet
->uType
= STRRET_WSTR
;
680 strRet
->u
.pOleStr
= pszPath
;
684 CoTaskMemFree(pszPath
);
686 TRACE ("-- (%p)->(%s,0x%08x)\n", This
,
687 strRet
->uType
== STRRET_CSTR
? strRet
->u
.cStr
:
688 debugstr_w(strRet
->u
.pOleStr
), hr
);
692 /**************************************************************************
693 * ISF_Desktop_fnSetNameOf
694 * Changes the name of a file object or subfolder, possibly changing its item
695 * identifier in the process.
698 * HWND hwndOwner, //[in ] Owner window for output
699 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
700 * LPCOLESTR lpszName, //[in ] the items new display name
701 * DWORD dwFlags, //[in ] SHGNO formatting flags
702 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
704 static HRESULT WINAPI
ISF_Desktop_fnSetNameOf (IShellFolder2
* iface
,
705 HWND hwndOwner
, LPCITEMIDLIST pidl
, /* simple pidl */
706 LPCOLESTR lpName
, DWORD dwFlags
, LPITEMIDLIST
* pPidlOut
)
708 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
710 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This
, hwndOwner
, pidl
,
711 debugstr_w (lpName
), dwFlags
, pPidlOut
);
716 static HRESULT WINAPI
ISF_Desktop_fnGetDefaultSearchGUID(IShellFolder2
*iface
,
719 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
721 FIXME ("(%p)\n", This
);
725 static HRESULT WINAPI
ISF_Desktop_fnEnumSearches (IShellFolder2
*iface
,
726 IEnumExtraSearch
** ppenum
)
728 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
729 FIXME ("(%p)\n", This
);
733 static HRESULT WINAPI
ISF_Desktop_fnGetDefaultColumn (IShellFolder2
* iface
,
734 DWORD dwRes
, ULONG
* pSort
, ULONG
* pDisplay
)
736 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
738 TRACE ("(%p)\n", This
);
747 static HRESULT WINAPI
ISF_Desktop_fnGetDefaultColumnState (
748 IShellFolder2
* iface
, UINT iColumn
, DWORD
* pcsFlags
)
750 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
752 TRACE ("(%p)\n", This
);
754 if (!pcsFlags
|| iColumn
>= DESKTOPSHELLVIEWCOLUMNS
)
757 *pcsFlags
= DesktopSFHeader
[iColumn
].pcsFlags
;
762 static HRESULT WINAPI
ISF_Desktop_fnGetDetailsEx (IShellFolder2
* iface
,
763 LPCITEMIDLIST pidl
, const SHCOLUMNID
* pscid
, VARIANT
* pv
)
765 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
766 FIXME ("(%p)\n", This
);
771 static HRESULT WINAPI
ISF_Desktop_fnGetDetailsOf (IShellFolder2
* iface
,
772 LPCITEMIDLIST pidl
, UINT iColumn
, SHELLDETAILS
* psd
)
774 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
778 TRACE ("(%p)->(%p %i %p)\n", This
, pidl
, iColumn
, psd
);
780 if (!psd
|| iColumn
>= DESKTOPSHELLVIEWCOLUMNS
)
785 psd
->fmt
= DesktopSFHeader
[iColumn
].fmt
;
786 psd
->cxChar
= DesktopSFHeader
[iColumn
].cxChar
;
787 psd
->str
.uType
= STRRET_CSTR
;
788 LoadStringA (shell32_hInstance
, DesktopSFHeader
[iColumn
].colnameid
,
789 psd
->str
.u
.cStr
, MAX_PATH
);
793 /* the data from the pidl */
794 psd
->str
.uType
= STRRET_CSTR
;
798 hr
= IShellFolder_GetDisplayNameOf(iface
, pidl
,
799 SHGDN_NORMAL
| SHGDN_INFOLDER
, &psd
->str
);
802 _ILGetFileSize (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
805 _ILGetFileType (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
808 _ILGetFileDate (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
810 case 4: /* attributes */
811 _ILGetFileAttributes (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
818 static HRESULT WINAPI
ISF_Desktop_fnMapColumnToSCID (
819 IShellFolder2
* iface
, UINT column
, SHCOLUMNID
* pscid
)
821 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
822 FIXME ("(%p)\n", This
);
826 static const IShellFolder2Vtbl vt_MCFldr_ShellFolder2
=
828 ISF_Desktop_fnQueryInterface
,
829 ISF_Desktop_fnAddRef
,
830 ISF_Desktop_fnRelease
,
831 ISF_Desktop_fnParseDisplayName
,
832 ISF_Desktop_fnEnumObjects
,
833 ISF_Desktop_fnBindToObject
,
834 ISF_Desktop_fnBindToStorage
,
835 ISF_Desktop_fnCompareIDs
,
836 ISF_Desktop_fnCreateViewObject
,
837 ISF_Desktop_fnGetAttributesOf
,
838 ISF_Desktop_fnGetUIObjectOf
,
839 ISF_Desktop_fnGetDisplayNameOf
,
840 ISF_Desktop_fnSetNameOf
,
842 ISF_Desktop_fnGetDefaultSearchGUID
,
843 ISF_Desktop_fnEnumSearches
,
844 ISF_Desktop_fnGetDefaultColumn
,
845 ISF_Desktop_fnGetDefaultColumnState
,
846 ISF_Desktop_fnGetDetailsEx
,
847 ISF_Desktop_fnGetDetailsOf
,
848 ISF_Desktop_fnMapColumnToSCID
851 static inline IGenericSFImpl
*impl_from_IPersistFolder2( IPersistFolder2
*iface
)
853 return (IGenericSFImpl
*)((char*)iface
- FIELD_OFFSET(IGenericSFImpl
, lpPF2
));
856 static HRESULT WINAPI
857 ISF_Desktop_PersistFolder2_fnQueryInterface (IPersistFolder2
* iface
, REFIID iid
,
860 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
862 TRACE ("(%p)\n", This
);
864 return ISF_Desktop_fnQueryInterface ((IShellFolder2
*)This
, iid
, ppvObj
);
868 ISF_Desktop_PersistFolder2_fnAddRef (IPersistFolder2
* iface
)
870 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
872 TRACE ("(%p)->(count=%u)\n", This
, This
->ref
);
874 return ISF_Desktop_fnAddRef((IShellFolder2
*)This
);
878 ISF_Desktop_PersistFolder2_fnRelease (IPersistFolder2
* iface
)
880 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
882 TRACE ("(%p)->(count=%u)\n", This
, This
->ref
);
884 return ISF_Desktop_fnRelease ((IShellFolder2
*)This
);
887 static HRESULT WINAPI
888 ISF_Desktop_PersistFolder2_fnGetClassID (IPersistFolder2
* iface
, CLSID
* lpClassId
)
890 static GUID
const CLSID_Desktop
=
891 { 0x00021400, 0x0000, 0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46} };
893 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
895 TRACE ("(%p)\n", This
);
900 memcpy(lpClassId
, &CLSID_Desktop
, sizeof(GUID
));
904 static HRESULT WINAPI
905 ISF_Desktop_PersistFolder2_fnInitialize (IPersistFolder2
* iface
, LPCITEMIDLIST pidl
)
907 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
909 TRACE ("(%p)->(%p)\n", This
, pidl
);
914 static HRESULT WINAPI
915 ISF_Desktop_PersistFolder2_fnGetCurFolder (IPersistFolder2
* iface
,
918 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
920 TRACE ("(%p)->(%p)\n", This
, pidl
);
922 if (!pidl
) return E_POINTER
;
923 *pidl
= ILClone (This
->pidlRoot
);
927 static const IPersistFolder2Vtbl vt_FSFldr_PersistFolder2
=
929 ISF_Desktop_PersistFolder2_fnQueryInterface
,
930 ISF_Desktop_PersistFolder2_fnAddRef
,
931 ISF_Desktop_PersistFolder2_fnRelease
,
932 ISF_Desktop_PersistFolder2_fnGetClassID
,
933 ISF_Desktop_PersistFolder2_fnInitialize
,
934 ISF_Desktop_PersistFolder2_fnGetCurFolder
,
938 /**************************************************************************
939 * ISF_Desktop_Constructor
941 HRESULT WINAPI
ISF_Desktop_Constructor (
942 IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
944 static IGenericSFImpl
*cached_sf
;
945 WCHAR szMyPath
[MAX_PATH
];
947 TRACE ("unkOut=%p %s\n", pUnkOuter
, shdebugstr_guid (riid
));
952 return CLASS_E_NOAGGREGATION
;
958 if (!SHGetSpecialFolderPathW( 0, szMyPath
, CSIDL_DESKTOPDIRECTORY
, TRUE
))
961 sf
= LocalAlloc( LMEM_ZEROINIT
, sizeof (IGenericSFImpl
) );
963 return E_OUTOFMEMORY
;
966 sf
->lpVtbl
= &vt_MCFldr_ShellFolder2
;
967 sf
->lpPF2
= &vt_FSFldr_PersistFolder2
;
968 sf
->pidlRoot
= _ILCreateDesktop(); /* my qualified pidl */
969 sf
->sPathTarget
= SHAlloc( (lstrlenW(szMyPath
) + 1)*sizeof(WCHAR
) );
970 lstrcpyW( sf
->sPathTarget
, szMyPath
);
972 if (InterlockedCompareExchangePointer((void *)&cached_sf
, sf
, NULL
) != NULL
)
974 /* some other thread already been here */
975 SHFree( sf
->pidlRoot
);
976 SHFree( sf
->sPathTarget
);
981 return IUnknown_QueryInterface( _IUnknown_(cached_sf
), riid
, ppv
);