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 /* Undocumented functions from shdocvw */
59 extern HRESULT WINAPI
IEParseDisplayNameWithBCW(DWORD codepage
, LPCWSTR lpszDisplayName
, LPBC pbc
, LPITEMIDLIST
*ppidl
);
62 /***********************************************************************
63 * Desktopfolder implementation
67 const IShellFolder2Vtbl
*lpVtbl
;
70 /* both paths are parsible from the desktop */
71 LPWSTR sPathTarget
; /* complete path to target used for enumeration and ChangeNotify */
72 LPITEMIDLIST pidlRoot
; /* absolute pidl */
74 UINT cfShellIDList
; /* clipboardformat for IDropTarget */
75 BOOL fAcceptFmt
; /* flag for pending Drop */
78 #define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl)
79 #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
81 static const shvheader DesktopSFHeader
[] = {
82 {IDS_SHV_COLUMN1
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 15},
83 {IDS_SHV_COLUMN2
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
84 {IDS_SHV_COLUMN3
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
85 {IDS_SHV_COLUMN4
, SHCOLSTATE_TYPE_DATE
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 12},
86 {IDS_SHV_COLUMN5
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 5}
89 #define DESKTOPSHELLVIEWCOLUMNS 5
91 /**************************************************************************
92 * ISF_Desktop_fnQueryInterface
94 * NOTES supports not IPersist/IPersistFolder
96 static HRESULT WINAPI
ISF_Desktop_fnQueryInterface(
97 IShellFolder2
* iface
, REFIID riid
, LPVOID
* ppvObj
)
99 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
101 TRACE ("(%p)->(%s,%p)\n", This
, shdebugstr_guid (riid
), ppvObj
);
105 if (IsEqualIID (riid
, &IID_IUnknown
) ||
106 IsEqualIID (riid
, &IID_IShellFolder
) ||
107 IsEqualIID (riid
, &IID_IShellFolder2
))
114 IUnknown_AddRef ((IUnknown
*) (*ppvObj
));
115 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj
, *ppvObj
);
118 TRACE ("-- Interface: E_NOINTERFACE\n");
119 return E_NOINTERFACE
;
122 static ULONG WINAPI
ISF_Desktop_fnAddRef (IShellFolder2
* iface
)
124 return 2; /* non-heap based object */
127 static ULONG WINAPI
ISF_Desktop_fnRelease (IShellFolder2
* iface
)
129 return 1; /* non-heap based object */
132 /**************************************************************************
133 * ISF_Desktop_fnParseDisplayName
136 * "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds
139 static HRESULT WINAPI
ISF_Desktop_fnParseDisplayName (IShellFolder2
* iface
,
140 HWND hwndOwner
, LPBC pbc
, LPOLESTR lpszDisplayName
,
141 DWORD
* pchEaten
, LPITEMIDLIST
* ppidl
, DWORD
* pdwAttributes
)
143 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
144 WCHAR szElement
[MAX_PATH
];
145 LPCWSTR szNext
= NULL
;
146 LPITEMIDLIST pidlTemp
= NULL
;
150 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
151 This
, hwndOwner
, pbc
, lpszDisplayName
, debugstr_w(lpszDisplayName
),
152 pchEaten
, ppidl
, pdwAttributes
);
154 if (!lpszDisplayName
|| !ppidl
)
160 *pchEaten
= 0; /* strange but like the original */
162 if (lpszDisplayName
[0] == ':' && lpszDisplayName
[1] == ':')
164 szNext
= GetNextElementW (lpszDisplayName
, szElement
, MAX_PATH
);
165 TRACE ("-- element: %s\n", debugstr_w (szElement
));
166 SHCLSIDFromStringW (szElement
+ 2, &clsid
);
167 pidlTemp
= _ILCreateGuid (PT_GUID
, &clsid
);
169 else if (PathGetDriveNumberW (lpszDisplayName
) >= 0)
171 /* it's a filesystem path with a drive. Let MyComputer/UnixDosFolder parse it */
172 if (UNIXFS_is_rooted_at_desktop())
173 pidlTemp
= _ILCreateGuid(PT_GUID
, &CLSID_UnixDosFolder
);
175 pidlTemp
= _ILCreateMyComputer ();
176 szNext
= lpszDisplayName
;
178 else if (PathIsUNCW(lpszDisplayName
))
180 pidlTemp
= _ILCreateNetwork();
181 szNext
= lpszDisplayName
;
183 else if( (pidlTemp
= SHELL32_CreatePidlFromBindCtx(pbc
, lpszDisplayName
)) )
188 else if (strchrW(lpszDisplayName
,':'))
192 urldata
.cbSize
= sizeof(urldata
);
193 ParseURLW(lpszDisplayName
,&urldata
);
195 if (urldata
.nScheme
== URL_SCHEME_SHELL
) /* handle shell: urls */
197 TRACE ("-- shell url: %s\n", debugstr_w(urldata
.pszSuffix
));
198 SHCLSIDFromStringW (urldata
.pszSuffix
+2, &clsid
);
199 pidlTemp
= _ILCreateGuid (PT_GUID
, &clsid
);
202 return IEParseDisplayNameWithBCW(CP_ACP
,lpszDisplayName
,pbc
,ppidl
);
206 /* it's a filesystem path on the desktop. Let a FSFolder parse it */
208 if (*lpszDisplayName
)
210 WCHAR szPath
[MAX_PATH
];
213 /* build a complete path to create a simple pidl */
214 lstrcpynW(szPath
, This
->sPathTarget
, MAX_PATH
);
215 pathPtr
= PathAddBackslashW(szPath
);
218 lstrcpynW(pathPtr
, lpszDisplayName
, MAX_PATH
- (pathPtr
- szPath
));
219 hr
= _ILCreateFromPathW(szPath
, &pidlTemp
);
223 /* should never reach here, but for completeness */
224 hr
= HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
);
228 pidlTemp
= _ILCreateMyComputer();
233 if (SUCCEEDED(hr
) && pidlTemp
)
235 if (szNext
&& *szNext
)
237 hr
= SHELL32_ParseNextElement(iface
, hwndOwner
, pbc
,
238 &pidlTemp
, (LPOLESTR
) szNext
, pchEaten
, pdwAttributes
);
242 if (pdwAttributes
&& *pdwAttributes
)
243 hr
= SHELL32_GetItemAttributes(_IShellFolder_ (This
),
244 pidlTemp
, pdwAttributes
);
250 TRACE ("(%p)->(-- ret=0x%08x)\n", This
, hr
);
255 /**************************************************************************
256 * CreateDesktopEnumList()
258 static const WCHAR Desktop_NameSpaceW
[] = { 'S','O','F','T','W','A','R','E',
259 '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
260 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l',
261 'o','r','e','r','\\','D','e','s','k','t','o','p','\\','N','a','m','e','s','p',
264 static BOOL
CreateDesktopEnumList(IEnumIDList
*list
, DWORD dwFlags
)
267 WCHAR szPath
[MAX_PATH
];
269 TRACE("(%p)->(flags=0x%08x)\n", list
, dwFlags
);
271 /* enumerate the root folders */
272 if (dwFlags
& SHCONTF_FOLDERS
)
277 /* create the pidl for This item */
278 ret
= AddToEnumList(list
, _ILCreateMyComputer());
280 for (i
=0; i
<2; i
++) {
281 if (ret
&& !RegOpenKeyExW(i
== 0 ? HKEY_LOCAL_MACHINE
: HKEY_CURRENT_USER
,
282 Desktop_NameSpaceW
, 0, KEY_READ
, &hkey
))
292 size
= sizeof (iid
) / sizeof (iid
[0]);
293 r
= RegEnumKeyExW(hkey
, i
, iid
, &size
, 0, NULL
, NULL
, NULL
);
294 if (ERROR_SUCCESS
== r
)
296 ret
= AddToEnumList(list
, _ILCreateGuidFromStrW(iid
));
299 else if (ERROR_NO_MORE_ITEMS
== r
)
309 /* enumerate the elements in %windir%\desktop */
310 SHGetSpecialFolderPathW(0, szPath
, CSIDL_DESKTOPDIRECTORY
, FALSE
);
311 ret
= ret
&& CreateFolderEnumList(list
, szPath
, dwFlags
);
316 /**************************************************************************
317 * ISF_Desktop_fnEnumObjects
319 static HRESULT WINAPI
ISF_Desktop_fnEnumObjects (IShellFolder2
* iface
,
320 HWND hwndOwner
, DWORD dwFlags
, LPENUMIDLIST
* ppEnumIDList
)
322 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
324 TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n",
325 This
, hwndOwner
, dwFlags
, ppEnumIDList
);
327 *ppEnumIDList
= IEnumIDList_Constructor();
329 CreateDesktopEnumList(*ppEnumIDList
, dwFlags
);
331 TRACE ("-- (%p)->(new ID List: %p)\n", This
, *ppEnumIDList
);
333 return *ppEnumIDList
? S_OK
: E_OUTOFMEMORY
;
336 /**************************************************************************
337 * ISF_Desktop_fnBindToObject
339 static HRESULT WINAPI
ISF_Desktop_fnBindToObject (IShellFolder2
* iface
,
340 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
342 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
344 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n",
345 This
, pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
347 return SHELL32_BindToChild( This
->pidlRoot
, This
->sPathTarget
, pidl
, riid
, ppvOut
);
350 /**************************************************************************
351 * ISF_Desktop_fnBindToStorage
353 static HRESULT WINAPI
ISF_Desktop_fnBindToStorage (IShellFolder2
* iface
,
354 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
356 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
358 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n",
359 This
, pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
365 /**************************************************************************
366 * ISF_Desktop_fnCompareIDs
368 static HRESULT WINAPI
ISF_Desktop_fnCompareIDs (IShellFolder2
* iface
,
369 LPARAM lParam
, LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
371 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
374 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This
, lParam
, pidl1
, pidl2
);
375 nReturn
= SHELL32_CompareIDs (_IShellFolder_ (This
), lParam
, pidl1
, pidl2
);
376 TRACE ("-- %i\n", nReturn
);
380 /**************************************************************************
381 * ISF_Desktop_fnCreateViewObject
383 static HRESULT WINAPI
ISF_Desktop_fnCreateViewObject (IShellFolder2
* iface
,
384 HWND hwndOwner
, REFIID riid
, LPVOID
* ppvOut
)
386 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
387 LPSHELLVIEW pShellView
;
388 HRESULT hr
= E_INVALIDARG
;
390 TRACE ("(%p)->(hwnd=%p,%s,%p)\n",
391 This
, hwndOwner
, shdebugstr_guid (riid
), ppvOut
);
398 if (IsEqualIID (riid
, &IID_IDropTarget
))
400 WARN ("IDropTarget not implemented\n");
403 else if (IsEqualIID (riid
, &IID_IContextMenu
))
405 WARN ("IContextMenu not implemented\n");
408 else if (IsEqualIID (riid
, &IID_IShellView
))
410 pShellView
= IShellView_Constructor ((IShellFolder
*) iface
);
413 hr
= IShellView_QueryInterface (pShellView
, riid
, ppvOut
);
414 IShellView_Release (pShellView
);
417 TRACE ("-- (%p)->(interface=%p)\n", This
, ppvOut
);
421 /**************************************************************************
422 * ISF_Desktop_fnGetAttributesOf
424 static HRESULT WINAPI
ISF_Desktop_fnGetAttributesOf (IShellFolder2
* iface
,
425 UINT cidl
, LPCITEMIDLIST
* apidl
, DWORD
* rgfInOut
)
427 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
429 static const DWORD dwDesktopAttributes
=
430 SFGAO_STORAGE
| SFGAO_HASPROPSHEET
| SFGAO_STORAGEANCESTOR
|
431 SFGAO_FILESYSANCESTOR
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_HASSUBFOLDER
;
432 static const DWORD dwMyComputerAttributes
=
433 SFGAO_CANRENAME
| SFGAO_CANDELETE
| SFGAO_HASPROPSHEET
|
434 SFGAO_DROPTARGET
| SFGAO_FILESYSANCESTOR
| SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
;
436 TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
437 This
, cidl
, apidl
, rgfInOut
, rgfInOut
? *rgfInOut
: 0);
448 *rgfInOut
&= dwDesktopAttributes
;
450 while (cidl
> 0 && *apidl
) {
452 if (_ILIsDesktop(*apidl
)) {
453 *rgfInOut
&= dwDesktopAttributes
;
454 } else if (_ILIsMyComputer(*apidl
)) {
455 *rgfInOut
&= dwMyComputerAttributes
;
457 SHELL32_GetItemAttributes (_IShellFolder_ (This
), *apidl
, rgfInOut
);
463 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
464 *rgfInOut
&= ~SFGAO_VALIDATE
;
466 TRACE ("-- result=0x%08x\n", *rgfInOut
);
471 /**************************************************************************
472 * ISF_Desktop_fnGetUIObjectOf
475 * HWND hwndOwner, //[in ] Parent window for any output
476 * UINT cidl, //[in ] array size
477 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
478 * REFIID riid, //[in ] Requested Interface
479 * UINT* prgfInOut, //[ ] reserved
480 * LPVOID* ppvObject) //[out] Resulting Interface
483 static HRESULT WINAPI
ISF_Desktop_fnGetUIObjectOf (IShellFolder2
* iface
,
484 HWND hwndOwner
, UINT cidl
, LPCITEMIDLIST
* apidl
,
485 REFIID riid
, UINT
* prgfInOut
, LPVOID
* ppvOut
)
487 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
490 IUnknown
*pObj
= NULL
;
491 HRESULT hr
= E_INVALIDARG
;
493 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
494 This
, hwndOwner
, cidl
, apidl
, shdebugstr_guid (riid
), prgfInOut
, ppvOut
);
501 if (IsEqualIID (riid
, &IID_IContextMenu
))
504 pObj
= (LPUNKNOWN
) ISvItemCm_Constructor( (IShellFolder
*) iface
, This
->pidlRoot
, apidl
, cidl
);
506 pObj
= (LPUNKNOWN
) ISvBgCm_Constructor( (IShellFolder
*) iface
, TRUE
);
509 else if (IsEqualIID (riid
, &IID_IDataObject
) && (cidl
>= 1))
511 pObj
= (LPUNKNOWN
) IDataObject_Constructor( hwndOwner
,
512 This
->pidlRoot
, apidl
, cidl
);
515 else if (IsEqualIID (riid
, &IID_IExtractIconA
) && (cidl
== 1))
517 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
518 pObj
= (LPUNKNOWN
) IExtractIconA_Constructor (pidl
);
522 else if (IsEqualIID (riid
, &IID_IExtractIconW
) && (cidl
== 1))
524 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
525 pObj
= (LPUNKNOWN
) IExtractIconW_Constructor (pidl
);
529 else if (IsEqualIID (riid
, &IID_IDropTarget
) && (cidl
>= 1))
531 hr
= IShellFolder_QueryInterface (iface
,
532 &IID_IDropTarget
, (LPVOID
*) & pObj
);
534 else if ((IsEqualIID(riid
,&IID_IShellLinkW
) ||
535 IsEqualIID(riid
,&IID_IShellLinkA
)) && (cidl
== 1))
537 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
538 hr
= IShellLink_ConstructFromFile(NULL
, riid
, pidl
, (LPVOID
*)&pObj
);
544 if (SUCCEEDED(hr
) && !pObj
)
548 TRACE ("(%p)->hr=0x%08x\n", This
, hr
);
552 /**************************************************************************
553 * ISF_Desktop_fnGetDisplayNameOf
556 * special case: pidl = null gives desktop-name back
558 static HRESULT WINAPI
ISF_Desktop_fnGetDisplayNameOf (IShellFolder2
* iface
,
559 LPCITEMIDLIST pidl
, DWORD dwFlags
, LPSTRRET strRet
)
561 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
565 TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This
, pidl
, dwFlags
, strRet
);
571 pszPath
= CoTaskMemAlloc((MAX_PATH
+1) * sizeof(WCHAR
));
573 return E_OUTOFMEMORY
;
575 if (_ILIsDesktop (pidl
))
577 if ((GET_SHGDN_RELATION (dwFlags
) == SHGDN_NORMAL
) &&
578 (GET_SHGDN_FOR (dwFlags
) & SHGDN_FORPARSING
))
579 strcpyW(pszPath
, This
->sPathTarget
);
581 HCR_GetClassNameW(&CLSID_ShellDesktop
, pszPath
, MAX_PATH
);
583 else if (_ILIsPidlSimple (pidl
))
587 if ((clsid
= _ILGetGUIDPointer (pidl
)))
589 if (GET_SHGDN_FOR (dwFlags
) & SHGDN_FORPARSING
)
591 int bWantsForParsing
;
594 * We can only get a filesystem path from a shellfolder if the
595 * value WantsFORPARSING in CLSID\\{...}\\shellfolder exists.
597 * Exception: The MyComputer folder doesn't have this key,
598 * but any other filesystem backed folder it needs it.
600 if (IsEqualIID (clsid
, &CLSID_MyComputer
))
602 bWantsForParsing
= TRUE
;
606 /* get the "WantsFORPARSING" flag from the registry */
607 static const WCHAR clsidW
[] =
608 { 'C','L','S','I','D','\\',0 };
609 static const WCHAR shellfolderW
[] =
610 { '\\','s','h','e','l','l','f','o','l','d','e','r',0 };
611 static const WCHAR wantsForParsingW
[] =
612 { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n',
614 WCHAR szRegPath
[100];
617 lstrcpyW (szRegPath
, clsidW
);
618 SHELL32_GUIDToStringW (clsid
, &szRegPath
[6]);
619 lstrcatW (szRegPath
, shellfolderW
);
620 r
= SHGetValueW(HKEY_CLASSES_ROOT
, szRegPath
,
621 wantsForParsingW
, NULL
, NULL
, NULL
);
622 if (r
== ERROR_SUCCESS
)
623 bWantsForParsing
= TRUE
;
625 bWantsForParsing
= FALSE
;
628 if ((GET_SHGDN_RELATION (dwFlags
) == SHGDN_NORMAL
) &&
632 * we need the filesystem path to the destination folder.
633 * Only the folder itself can know it
635 hr
= SHELL32_GetDisplayNameOfChild (iface
, pidl
, dwFlags
,
641 /* parsing name like ::{...} */
644 SHELL32_GUIDToStringW (clsid
, &pszPath
[2]);
649 /* user friendly name */
650 HCR_GetClassNameW (clsid
, pszPath
, MAX_PATH
);
657 /* file system folder or file rooted at the desktop */
658 if ((GET_SHGDN_FOR(dwFlags
) == SHGDN_FORPARSING
) &&
659 (GET_SHGDN_RELATION(dwFlags
) != SHGDN_INFOLDER
))
661 lstrcpynW(pszPath
, This
->sPathTarget
, MAX_PATH
- 1);
662 PathAddBackslashW(pszPath
);
663 cLen
= lstrlenW(pszPath
);
666 _ILSimpleGetTextW(pidl
, pszPath
+ cLen
, MAX_PATH
- cLen
);
668 if (!_ILIsFolder(pidl
))
669 SHELL_FS_ProcessDisplayFilename(pszPath
, dwFlags
);
674 /* a complex pidl, let the subfolder do the work */
675 hr
= SHELL32_GetDisplayNameOfChild (iface
, pidl
, dwFlags
,
681 /* Win9x always returns ANSI strings, NT always returns Unicode strings */
682 if (GetVersion() & 0x80000000)
684 strRet
->uType
= STRRET_CSTR
;
685 if (!WideCharToMultiByte(CP_ACP
, 0, pszPath
, -1, strRet
->u
.cStr
, MAX_PATH
,
687 strRet
->u
.cStr
[0] = '\0';
688 CoTaskMemFree(pszPath
);
692 strRet
->uType
= STRRET_WSTR
;
693 strRet
->u
.pOleStr
= pszPath
;
697 CoTaskMemFree(pszPath
);
699 TRACE ("-- (%p)->(%s,0x%08x)\n", This
,
700 strRet
->uType
== STRRET_CSTR
? strRet
->u
.cStr
:
701 debugstr_w(strRet
->u
.pOleStr
), hr
);
705 /**************************************************************************
706 * ISF_Desktop_fnSetNameOf
707 * Changes the name of a file object or subfolder, possibly changing its item
708 * identifier in the process.
711 * HWND hwndOwner, //[in ] Owner window for output
712 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
713 * LPCOLESTR lpszName, //[in ] the items new display name
714 * DWORD dwFlags, //[in ] SHGNO formatting flags
715 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
717 static HRESULT WINAPI
ISF_Desktop_fnSetNameOf (IShellFolder2
* iface
,
718 HWND hwndOwner
, LPCITEMIDLIST pidl
, /* simple pidl */
719 LPCOLESTR lpName
, DWORD dwFlags
, LPITEMIDLIST
* pPidlOut
)
721 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
723 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This
, hwndOwner
, pidl
,
724 debugstr_w (lpName
), dwFlags
, pPidlOut
);
729 static HRESULT WINAPI
ISF_Desktop_fnGetDefaultSearchGUID(IShellFolder2
*iface
,
732 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
734 FIXME ("(%p)\n", This
);
738 static HRESULT WINAPI
ISF_Desktop_fnEnumSearches (IShellFolder2
*iface
,
739 IEnumExtraSearch
** ppenum
)
741 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
742 FIXME ("(%p)\n", This
);
746 static HRESULT WINAPI
ISF_Desktop_fnGetDefaultColumn (IShellFolder2
* iface
,
747 DWORD dwRes
, ULONG
* pSort
, ULONG
* pDisplay
)
749 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
751 TRACE ("(%p)\n", This
);
760 static HRESULT WINAPI
ISF_Desktop_fnGetDefaultColumnState (
761 IShellFolder2
* iface
, UINT iColumn
, DWORD
* pcsFlags
)
763 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
765 TRACE ("(%p)\n", This
);
767 if (!pcsFlags
|| iColumn
>= DESKTOPSHELLVIEWCOLUMNS
)
770 *pcsFlags
= DesktopSFHeader
[iColumn
].pcsFlags
;
775 static HRESULT WINAPI
ISF_Desktop_fnGetDetailsEx (IShellFolder2
* iface
,
776 LPCITEMIDLIST pidl
, const SHCOLUMNID
* pscid
, VARIANT
* pv
)
778 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
779 FIXME ("(%p)\n", This
);
784 static HRESULT WINAPI
ISF_Desktop_fnGetDetailsOf (IShellFolder2
* iface
,
785 LPCITEMIDLIST pidl
, UINT iColumn
, SHELLDETAILS
* psd
)
787 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
791 TRACE ("(%p)->(%p %i %p)\n", This
, pidl
, iColumn
, psd
);
793 if (!psd
|| iColumn
>= DESKTOPSHELLVIEWCOLUMNS
)
798 psd
->fmt
= DesktopSFHeader
[iColumn
].fmt
;
799 psd
->cxChar
= DesktopSFHeader
[iColumn
].cxChar
;
800 psd
->str
.uType
= STRRET_CSTR
;
801 LoadStringA (shell32_hInstance
, DesktopSFHeader
[iColumn
].colnameid
,
802 psd
->str
.u
.cStr
, MAX_PATH
);
806 /* the data from the pidl */
807 psd
->str
.uType
= STRRET_CSTR
;
811 hr
= IShellFolder_GetDisplayNameOf(iface
, pidl
,
812 SHGDN_NORMAL
| SHGDN_INFOLDER
, &psd
->str
);
815 _ILGetFileSize (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
818 _ILGetFileType (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
821 _ILGetFileDate (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
823 case 4: /* attributes */
824 _ILGetFileAttributes (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
831 static HRESULT WINAPI
ISF_Desktop_fnMapColumnToSCID (
832 IShellFolder2
* iface
, UINT column
, SHCOLUMNID
* pscid
)
834 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
835 FIXME ("(%p)\n", This
);
839 static const IShellFolder2Vtbl vt_MCFldr_ShellFolder2
=
841 ISF_Desktop_fnQueryInterface
,
842 ISF_Desktop_fnAddRef
,
843 ISF_Desktop_fnRelease
,
844 ISF_Desktop_fnParseDisplayName
,
845 ISF_Desktop_fnEnumObjects
,
846 ISF_Desktop_fnBindToObject
,
847 ISF_Desktop_fnBindToStorage
,
848 ISF_Desktop_fnCompareIDs
,
849 ISF_Desktop_fnCreateViewObject
,
850 ISF_Desktop_fnGetAttributesOf
,
851 ISF_Desktop_fnGetUIObjectOf
,
852 ISF_Desktop_fnGetDisplayNameOf
,
853 ISF_Desktop_fnSetNameOf
,
855 ISF_Desktop_fnGetDefaultSearchGUID
,
856 ISF_Desktop_fnEnumSearches
,
857 ISF_Desktop_fnGetDefaultColumn
,
858 ISF_Desktop_fnGetDefaultColumnState
,
859 ISF_Desktop_fnGetDetailsEx
,
860 ISF_Desktop_fnGetDetailsOf
,
861 ISF_Desktop_fnMapColumnToSCID
864 /**************************************************************************
865 * ISF_Desktop_Constructor
867 HRESULT WINAPI
ISF_Desktop_Constructor (
868 IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
870 static IGenericSFImpl
*cached_sf
;
871 WCHAR szMyPath
[MAX_PATH
];
873 TRACE ("unkOut=%p %s\n", pUnkOuter
, shdebugstr_guid (riid
));
878 return CLASS_E_NOAGGREGATION
;
884 if (!SHGetSpecialFolderPathW( 0, szMyPath
, CSIDL_DESKTOPDIRECTORY
, TRUE
))
887 sf
= LocalAlloc( LMEM_ZEROINIT
, sizeof (IGenericSFImpl
) );
889 return E_OUTOFMEMORY
;
892 sf
->lpVtbl
= &vt_MCFldr_ShellFolder2
;
893 sf
->pidlRoot
= _ILCreateDesktop(); /* my qualified pidl */
894 sf
->sPathTarget
= SHAlloc( (lstrlenW(szMyPath
) + 1)*sizeof(WCHAR
) );
895 lstrcpyW( sf
->sPathTarget
, szMyPath
);
897 if (InterlockedCompareExchangePointer((void *)&cached_sf
, sf
, NULL
) != NULL
)
899 /* some other thread already been here */
900 SHFree( sf
->pidlRoot
);
901 SHFree( sf
->sPathTarget
);
906 return IUnknown_QueryInterface( _IUnknown_(cached_sf
), riid
, ppv
);