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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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
;
68 /* both paths are parsible from the desktop */
69 LPWSTR sPathTarget
; /* complete path to target used for enumeration and ChangeNotify */
70 LPITEMIDLIST pidlRoot
; /* absolute pidl */
72 UINT cfShellIDList
; /* clipboardformat for IDropTarget */
73 BOOL fAcceptFmt
; /* flag for pending Drop */
76 #define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl)
77 #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
79 static shvheader DesktopSFHeader
[] = {
80 {IDS_SHV_COLUMN1
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 15},
81 {IDS_SHV_COLUMN2
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
82 {IDS_SHV_COLUMN3
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
83 {IDS_SHV_COLUMN4
, SHCOLSTATE_TYPE_DATE
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 12},
84 {IDS_SHV_COLUMN5
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 5}
87 #define DESKTOPSHELLVIEWCOLUMNS 5
89 /**************************************************************************
90 * ISF_Desktop_fnQueryInterface
92 * NOTES supports not IPersist/IPersistFolder
94 static HRESULT WINAPI
ISF_Desktop_fnQueryInterface(
95 IShellFolder2
* iface
, REFIID riid
, LPVOID
* ppvObj
)
97 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
99 TRACE ("(%p)->(%s,%p)\n", This
, shdebugstr_guid (riid
), ppvObj
);
103 if (IsEqualIID (riid
, &IID_IUnknown
) ||
104 IsEqualIID (riid
, &IID_IShellFolder
) ||
105 IsEqualIID (riid
, &IID_IShellFolder2
))
112 IUnknown_AddRef ((IUnknown
*) (*ppvObj
));
113 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj
, *ppvObj
);
116 TRACE ("-- Interface: E_NOINTERFACE\n");
117 return E_NOINTERFACE
;
120 static ULONG WINAPI
ISF_Desktop_fnAddRef (IShellFolder2
* iface
)
122 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
123 ULONG refCount
= InterlockedIncrement(&This
->ref
);
125 TRACE ("(%p)->(count=%lu)\n", This
, refCount
- 1);
130 static ULONG WINAPI
ISF_Desktop_fnRelease (IShellFolder2
* iface
)
132 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
133 ULONG refCount
= InterlockedDecrement(&This
->ref
);
135 TRACE ("(%p)->(count=%lu)\n", This
, refCount
+ 1);
139 TRACE ("-- destroying IShellFolder(%p)\n", This
);
141 SHFree (This
->pidlRoot
);
142 if (This
->sPathTarget
)
143 SHFree (This
->sPathTarget
);
144 LocalFree ((HLOCAL
) This
);
150 /**************************************************************************
151 * ISF_Desktop_fnParseDisplayName
154 * "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds
157 static HRESULT WINAPI
ISF_Desktop_fnParseDisplayName (IShellFolder2
* iface
,
158 HWND hwndOwner
, LPBC pbc
, LPOLESTR lpszDisplayName
,
159 DWORD
* pchEaten
, LPITEMIDLIST
* ppidl
, DWORD
* pdwAttributes
)
161 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
162 WCHAR szElement
[MAX_PATH
];
163 LPCWSTR szNext
= NULL
;
164 LPITEMIDLIST pidlTemp
= NULL
;
168 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
169 This
, hwndOwner
, pbc
, lpszDisplayName
, debugstr_w(lpszDisplayName
),
170 pchEaten
, ppidl
, pdwAttributes
);
172 if (!lpszDisplayName
|| !ppidl
)
178 *pchEaten
= 0; /* strange but like the original */
180 if (lpszDisplayName
[0] == ':' && lpszDisplayName
[1] == ':')
182 szNext
= GetNextElementW (lpszDisplayName
, szElement
, MAX_PATH
);
183 TRACE ("-- element: %s\n", debugstr_w (szElement
));
184 SHCLSIDFromStringW (szElement
+ 2, &clsid
);
185 pidlTemp
= _ILCreateGuid (PT_GUID
, &clsid
);
187 else if (PathGetDriveNumberW (lpszDisplayName
) >= 0)
189 /* it's a filesystem path with a drive. Let MyComputer/UnixDosFolder parse it */
190 if (UNIXFS_is_rooted_at_desktop())
191 pidlTemp
= _ILCreateGuid(PT_GUID
, &CLSID_UnixDosFolder
);
193 pidlTemp
= _ILCreateMyComputer ();
194 szNext
= lpszDisplayName
;
196 else if (PathIsUNCW(lpszDisplayName
))
198 pidlTemp
= _ILCreateNetwork();
199 szNext
= lpszDisplayName
;
201 else if( (pidlTemp
= SHELL32_CreatePidlFromBindCtx(pbc
, lpszDisplayName
)) )
208 /* it's a filesystem path on the desktop. Let a FSFolder parse it */
210 if (*lpszDisplayName
)
212 WCHAR szPath
[MAX_PATH
];
215 /* build a complete path to create a simple pidl */
216 lstrcpynW(szPath
, This
->sPathTarget
, MAX_PATH
);
217 pathPtr
= PathAddBackslashW(szPath
);
220 lstrcpynW(pathPtr
, lpszDisplayName
, MAX_PATH
- (pathPtr
- szPath
));
221 hr
= _ILCreateFromPathW(szPath
, &pidlTemp
);
225 /* should never reach here, but for completeness */
226 hr
= HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
);
230 pidlTemp
= _ILCreateMyComputer();
235 if (SUCCEEDED(hr
) && pidlTemp
)
237 if (szNext
&& *szNext
)
239 hr
= SHELL32_ParseNextElement(iface
, hwndOwner
, pbc
,
240 &pidlTemp
, (LPOLESTR
) szNext
, pchEaten
, pdwAttributes
);
244 if (pdwAttributes
&& *pdwAttributes
)
245 hr
= SHELL32_GetItemAttributes(_IShellFolder_ (This
),
246 pidlTemp
, pdwAttributes
);
252 TRACE ("(%p)->(-- ret=0x%08lx)\n", This
, hr
);
257 /**************************************************************************
258 * CreateDesktopEnumList()
260 static const WCHAR Desktop_NameSpaceW
[] = { 'S','O','F','T','W','A','R','E',
261 '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
262 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l',
263 'o','r','e','r','\\','D','e','s','k','t','o','p','\\','N','a','m','e','s','p',
266 static BOOL
CreateDesktopEnumList(IEnumIDList
*list
, DWORD dwFlags
)
269 WCHAR szPath
[MAX_PATH
];
271 TRACE("(%p)->(flags=0x%08lx)\n", list
, dwFlags
);
273 /* enumerate the root folders */
274 if (dwFlags
& SHCONTF_FOLDERS
)
279 /* create the pidl for This item */
280 ret
= AddToEnumList(list
, _ILCreateMyComputer());
282 for (i
=0; i
<2; i
++) {
283 if (ret
&& !RegOpenKeyExW(i
== 0 ? HKEY_LOCAL_MACHINE
: HKEY_CURRENT_USER
,
284 Desktop_NameSpaceW
, 0, KEY_READ
, &hkey
))
295 r
= RegEnumKeyExW(hkey
, i
, iid
, &size
, 0, NULL
, NULL
, NULL
);
296 if (ERROR_SUCCESS
== r
)
298 ret
= AddToEnumList(list
, _ILCreateGuidFromStrW(iid
));
301 else if (ERROR_NO_MORE_ITEMS
== r
)
311 /* enumerate the elements in %windir%\desktop */
312 SHGetSpecialFolderPathW(0, szPath
, CSIDL_DESKTOPDIRECTORY
, FALSE
);
313 ret
= ret
&& CreateFolderEnumList(list
, szPath
, dwFlags
);
318 /**************************************************************************
319 * ISF_Desktop_fnEnumObjects
321 static HRESULT WINAPI
ISF_Desktop_fnEnumObjects (IShellFolder2
* iface
,
322 HWND hwndOwner
, DWORD dwFlags
, LPENUMIDLIST
* ppEnumIDList
)
324 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
326 TRACE ("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n",
327 This
, hwndOwner
, dwFlags
, ppEnumIDList
);
329 *ppEnumIDList
= IEnumIDList_Constructor();
331 CreateDesktopEnumList(*ppEnumIDList
, dwFlags
);
333 TRACE ("-- (%p)->(new ID List: %p)\n", This
, *ppEnumIDList
);
335 return *ppEnumIDList
? S_OK
: E_OUTOFMEMORY
;
338 /**************************************************************************
339 * ISF_Desktop_fnBindToObject
341 static HRESULT WINAPI
ISF_Desktop_fnBindToObject (IShellFolder2
* iface
,
342 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
344 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
346 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n",
347 This
, pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
349 return SHELL32_BindToChild( This
->pidlRoot
, This
->sPathTarget
, pidl
, riid
, ppvOut
);
352 /**************************************************************************
353 * ISF_Desktop_fnBindToStorage
355 static HRESULT WINAPI
ISF_Desktop_fnBindToStorage (IShellFolder2
* iface
,
356 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
358 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
360 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n",
361 This
, pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
367 /**************************************************************************
368 * ISF_Desktop_fnCompareIDs
370 static HRESULT WINAPI
ISF_Desktop_fnCompareIDs (IShellFolder2
* iface
,
371 LPARAM lParam
, LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
373 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
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
);
382 /**************************************************************************
383 * ISF_Desktop_fnCreateViewObject
385 static HRESULT WINAPI
ISF_Desktop_fnCreateViewObject (IShellFolder2
* iface
,
386 HWND hwndOwner
, REFIID riid
, LPVOID
* ppvOut
)
388 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
389 LPSHELLVIEW pShellView
;
390 HRESULT hr
= E_INVALIDARG
;
392 TRACE ("(%p)->(hwnd=%p,%s,%p)\n",
393 This
, hwndOwner
, shdebugstr_guid (riid
), ppvOut
);
400 if (IsEqualIID (riid
, &IID_IDropTarget
))
402 WARN ("IDropTarget not implemented\n");
405 else if (IsEqualIID (riid
, &IID_IContextMenu
))
407 WARN ("IContextMenu not implemented\n");
410 else if (IsEqualIID (riid
, &IID_IShellView
))
412 pShellView
= IShellView_Constructor ((IShellFolder
*) iface
);
415 hr
= IShellView_QueryInterface (pShellView
, riid
, ppvOut
);
416 IShellView_Release (pShellView
);
419 TRACE ("-- (%p)->(interface=%p)\n", This
, ppvOut
);
423 /**************************************************************************
424 * ISF_Desktop_fnGetAttributesOf
426 static HRESULT WINAPI
ISF_Desktop_fnGetAttributesOf (IShellFolder2
* iface
,
427 UINT cidl
, LPCITEMIDLIST
* apidl
, DWORD
* rgfInOut
)
429 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
431 static const DWORD dwDesktopAttributes
=
432 SFGAO_STORAGE
| SFGAO_HASPROPSHEET
| SFGAO_STORAGEANCESTOR
|
433 SFGAO_FILESYSANCESTOR
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_HASSUBFOLDER
;
434 static const DWORD dwMyComputerAttributes
=
435 SFGAO_CANRENAME
| SFGAO_CANDELETE
| SFGAO_HASPROPSHEET
|
436 SFGAO_DROPTARGET
| SFGAO_FILESYSANCESTOR
| SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
;
438 TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08lx))\n",
439 This
, cidl
, apidl
, rgfInOut
, rgfInOut
? *rgfInOut
: 0);
450 *rgfInOut
&= dwDesktopAttributes
;
452 while (cidl
> 0 && *apidl
) {
454 if (_ILIsDesktop(*apidl
)) {
455 *rgfInOut
&= dwDesktopAttributes
;
456 } else if (_ILIsMyComputer(*apidl
)) {
457 *rgfInOut
&= dwMyComputerAttributes
;
459 SHELL32_GetItemAttributes (_IShellFolder_ (This
), *apidl
, rgfInOut
);
465 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
466 *rgfInOut
&= ~SFGAO_VALIDATE
;
468 TRACE ("-- result=0x%08lx\n", *rgfInOut
);
473 /**************************************************************************
474 * ISF_Desktop_fnGetUIObjectOf
477 * HWND hwndOwner, //[in ] Parent window for any output
478 * UINT cidl, //[in ] array size
479 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
480 * REFIID riid, //[in ] Requested Interface
481 * UINT* prgfInOut, //[ ] reserved
482 * LPVOID* ppvObject) //[out] Resulting Interface
485 static HRESULT WINAPI
ISF_Desktop_fnGetUIObjectOf (IShellFolder2
* iface
,
486 HWND hwndOwner
, UINT cidl
, LPCITEMIDLIST
* apidl
,
487 REFIID riid
, UINT
* prgfInOut
, LPVOID
* ppvOut
)
489 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
492 IUnknown
*pObj
= NULL
;
493 HRESULT hr
= E_INVALIDARG
;
495 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
496 This
, hwndOwner
, cidl
, apidl
, shdebugstr_guid (riid
), prgfInOut
, ppvOut
);
503 if (IsEqualIID (riid
, &IID_IContextMenu
))
506 pObj
= (LPUNKNOWN
) ISvItemCm_Constructor( (IShellFolder
*) iface
, This
->pidlRoot
, apidl
, cidl
);
508 pObj
= (LPUNKNOWN
) ISvBgCm_Constructor( (IShellFolder
*) iface
, TRUE
);
511 else if (IsEqualIID (riid
, &IID_IDataObject
) && (cidl
>= 1))
513 pObj
= (LPUNKNOWN
) IDataObject_Constructor( hwndOwner
,
514 This
->pidlRoot
, apidl
, cidl
);
517 else if (IsEqualIID (riid
, &IID_IExtractIconA
) && (cidl
== 1))
519 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
520 pObj
= (LPUNKNOWN
) IExtractIconA_Constructor (pidl
);
524 else if (IsEqualIID (riid
, &IID_IExtractIconW
) && (cidl
== 1))
526 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
527 pObj
= (LPUNKNOWN
) IExtractIconW_Constructor (pidl
);
531 else if (IsEqualIID (riid
, &IID_IDropTarget
) && (cidl
>= 1))
533 hr
= IShellFolder_QueryInterface (iface
,
534 &IID_IDropTarget
, (LPVOID
*) & pObj
);
536 else if ((IsEqualIID(riid
,&IID_IShellLinkW
) ||
537 IsEqualIID(riid
,&IID_IShellLinkA
)) && (cidl
== 1))
539 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
540 hr
= IShellLink_ConstructFromFile(NULL
, riid
, pidl
, (LPVOID
*)&pObj
);
546 if (SUCCEEDED(hr
) && !pObj
)
550 TRACE ("(%p)->hr=0x%08lx\n", This
, hr
);
554 /**************************************************************************
555 * ISF_Desktop_fnGetDisplayNameOf
558 * special case: pidl = null gives desktop-name back
560 static HRESULT WINAPI
ISF_Desktop_fnGetDisplayNameOf (IShellFolder2
* iface
,
561 LPCITEMIDLIST pidl
, DWORD dwFlags
, LPSTRRET strRet
)
563 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
566 TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This
, pidl
, dwFlags
, strRet
);
572 strRet
->uType
= STRRET_CSTR
;
573 if (_ILIsDesktop (pidl
))
575 if ((GET_SHGDN_RELATION (dwFlags
) == SHGDN_NORMAL
) &&
576 (GET_SHGDN_FOR (dwFlags
) & SHGDN_FORPARSING
))
580 WideCharToMultiByte( CP_ACP
, 0, This
->sPathTarget
, -1,
581 strRet
->u
.cStr
, MAX_PATH
, NULL
, &defCharUsed
);
584 strRet
->u
.pOleStr
= SHAlloc((lstrlenW(This
->sPathTarget
)+1) *
586 if (!strRet
->u
.pOleStr
)
590 strcpyW(strRet
->u
.pOleStr
, This
->sPathTarget
);
591 strRet
->uType
= STRRET_WSTR
;
597 HCR_GetClassNameA(&CLSID_ShellDesktop
, strRet
->u
.cStr
, MAX_PATH
);
600 else if (_ILIsPidlSimple (pidl
))
604 if ((clsid
= _ILGetGUIDPointer (pidl
)))
606 if (GET_SHGDN_FOR (dwFlags
) & SHGDN_FORPARSING
)
608 int bWantsForParsing
;
611 * We can only get a filesystem path from a shellfolder if the
612 * value WantsFORPARSING in CLSID\\{...}\\shellfolder exists.
614 * Exception: The MyComputer folder doesn't have this key,
615 * but any other filesystem backed folder it needs it.
617 if (IsEqualIID (clsid
, &CLSID_MyComputer
))
619 bWantsForParsing
= TRUE
;
623 /* get the "WantsFORPARSING" flag from the registry */
624 static const WCHAR clsidW
[] =
625 { 'C','L','S','I','D','\\',0 };
626 static const WCHAR shellfolderW
[] =
627 { '\\','s','h','e','l','l','f','o','l','d','e','r',0 };
628 static const WCHAR wantsForParsingW
[] =
629 { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n',
631 WCHAR szRegPath
[100];
634 lstrcpyW (szRegPath
, clsidW
);
635 SHELL32_GUIDToStringW (clsid
, &szRegPath
[6]);
636 lstrcatW (szRegPath
, shellfolderW
);
637 r
= SHGetValueW(HKEY_CLASSES_ROOT
, szRegPath
,
638 wantsForParsingW
, NULL
, NULL
, NULL
);
639 if (r
== ERROR_SUCCESS
)
640 bWantsForParsing
= TRUE
;
642 bWantsForParsing
= FALSE
;
645 if ((GET_SHGDN_RELATION (dwFlags
) == SHGDN_NORMAL
) &&
649 * we need the filesystem path to the destination folder.
650 * Only the folder itself can know it
652 hr
= SHELL32_GetDisplayNameOfChild (iface
, pidl
, dwFlags
,
658 /* parsing name like ::{...} */
659 lstrcpyA (strRet
->u
.cStr
, "::");
660 SHELL32_GUIDToStringA (clsid
, &strRet
->u
.cStr
[2]);
665 /* user friendly name */
666 HCR_GetClassNameA (clsid
, strRet
->u
.cStr
, MAX_PATH
);
673 /* file system folder or file rooted at the desktop */
674 if ((GET_SHGDN_FOR(dwFlags
) == SHGDN_FORPARSING
) &&
675 (GET_SHGDN_RELATION(dwFlags
) != SHGDN_INFOLDER
))
677 WideCharToMultiByte(CP_ACP
, 0, This
->sPathTarget
, -1, strRet
->u
.cStr
, MAX_PATH
,
679 PathAddBackslashA(strRet
->u
.cStr
);
680 cLen
= lstrlenA(strRet
->u
.cStr
);
683 _ILSimpleGetText (pidl
, strRet
->u
.cStr
+ cLen
, MAX_PATH
- cLen
);
685 if (!_ILIsFolder(pidl
))
686 SHELL_FS_ProcessDisplayFilename(strRet
->u
.cStr
, dwFlags
);
691 /* a complex pidl, let the subfolder do the work */
692 hr
= SHELL32_GetDisplayNameOfChild (iface
, pidl
, dwFlags
,
693 strRet
->u
.cStr
, MAX_PATH
);
696 TRACE ("-- (%p)->(%s,0x%08lx)\n", This
,
697 strRet
->uType
== STRRET_CSTR
? strRet
->u
.cStr
:
698 debugstr_w(strRet
->u
.pOleStr
), hr
);
702 /**************************************************************************
703 * ISF_Desktop_fnSetNameOf
704 * Changes the name of a file object or subfolder, possibly changing its item
705 * identifier in the process.
708 * HWND hwndOwner, //[in ] Owner window for output
709 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
710 * LPCOLESTR lpszName, //[in ] the items new display name
711 * DWORD dwFlags, //[in ] SHGNO formatting flags
712 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
714 static HRESULT WINAPI
ISF_Desktop_fnSetNameOf (IShellFolder2
* iface
,
715 HWND hwndOwner
, LPCITEMIDLIST pidl
, /* simple pidl */
716 LPCOLESTR lpName
, DWORD dwFlags
, LPITEMIDLIST
* pPidlOut
)
718 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
720 FIXME ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This
, hwndOwner
, pidl
,
721 debugstr_w (lpName
), dwFlags
, pPidlOut
);
726 static HRESULT WINAPI
ISF_Desktop_fnGetDefaultSearchGUID(IShellFolder2
*iface
,
729 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
731 FIXME ("(%p)\n", This
);
735 static HRESULT WINAPI
ISF_Desktop_fnEnumSearches (IShellFolder2
*iface
,
736 IEnumExtraSearch
** ppenum
)
738 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
739 FIXME ("(%p)\n", This
);
743 static HRESULT WINAPI
ISF_Desktop_fnGetDefaultColumn (IShellFolder2
* iface
,
744 DWORD dwRes
, ULONG
* pSort
, ULONG
* pDisplay
)
746 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
748 TRACE ("(%p)\n", This
);
757 static HRESULT WINAPI
ISF_Desktop_fnGetDefaultColumnState (
758 IShellFolder2
* iface
, UINT iColumn
, DWORD
* pcsFlags
)
760 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
762 TRACE ("(%p)\n", This
);
764 if (!pcsFlags
|| iColumn
>= DESKTOPSHELLVIEWCOLUMNS
)
767 *pcsFlags
= DesktopSFHeader
[iColumn
].pcsFlags
;
772 static HRESULT WINAPI
ISF_Desktop_fnGetDetailsEx (IShellFolder2
* iface
,
773 LPCITEMIDLIST pidl
, const SHCOLUMNID
* pscid
, VARIANT
* pv
)
775 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
776 FIXME ("(%p)\n", This
);
781 static HRESULT WINAPI
ISF_Desktop_fnGetDetailsOf (IShellFolder2
* iface
,
782 LPCITEMIDLIST pidl
, UINT iColumn
, SHELLDETAILS
* psd
)
784 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
788 TRACE ("(%p)->(%p %i %p)\n", This
, pidl
, iColumn
, psd
);
790 if (!psd
|| iColumn
>= DESKTOPSHELLVIEWCOLUMNS
)
795 psd
->fmt
= DesktopSFHeader
[iColumn
].fmt
;
796 psd
->cxChar
= DesktopSFHeader
[iColumn
].cxChar
;
797 psd
->str
.uType
= STRRET_CSTR
;
798 LoadStringA (shell32_hInstance
, DesktopSFHeader
[iColumn
].colnameid
,
799 psd
->str
.u
.cStr
, MAX_PATH
);
803 /* the data from the pidl */
804 psd
->str
.uType
= STRRET_CSTR
;
808 hr
= IShellFolder_GetDisplayNameOf(iface
, pidl
,
809 SHGDN_NORMAL
| SHGDN_INFOLDER
, &psd
->str
);
812 _ILGetFileSize (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
815 _ILGetFileType (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
818 _ILGetFileDate (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
820 case 4: /* attributes */
821 _ILGetFileAttributes (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
828 static HRESULT WINAPI
ISF_Desktop_fnMapColumnToSCID (
829 IShellFolder2
* iface
, UINT column
, SHCOLUMNID
* pscid
)
831 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
832 FIXME ("(%p)\n", This
);
836 static const IShellFolder2Vtbl vt_MCFldr_ShellFolder2
=
838 ISF_Desktop_fnQueryInterface
,
839 ISF_Desktop_fnAddRef
,
840 ISF_Desktop_fnRelease
,
841 ISF_Desktop_fnParseDisplayName
,
842 ISF_Desktop_fnEnumObjects
,
843 ISF_Desktop_fnBindToObject
,
844 ISF_Desktop_fnBindToStorage
,
845 ISF_Desktop_fnCompareIDs
,
846 ISF_Desktop_fnCreateViewObject
,
847 ISF_Desktop_fnGetAttributesOf
,
848 ISF_Desktop_fnGetUIObjectOf
,
849 ISF_Desktop_fnGetDisplayNameOf
,
850 ISF_Desktop_fnSetNameOf
,
852 ISF_Desktop_fnGetDefaultSearchGUID
,
853 ISF_Desktop_fnEnumSearches
,
854 ISF_Desktop_fnGetDefaultColumn
,
855 ISF_Desktop_fnGetDefaultColumnState
,
856 ISF_Desktop_fnGetDetailsEx
,
857 ISF_Desktop_fnGetDetailsOf
,
858 ISF_Desktop_fnMapColumnToSCID
861 /**************************************************************************
862 * ISF_Desktop_Constructor
864 HRESULT WINAPI
ISF_Desktop_Constructor (
865 IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
868 WCHAR szMyPath
[MAX_PATH
];
871 TRACE ("unkOut=%p %s\n", pUnkOuter
, shdebugstr_guid (riid
));
876 return CLASS_E_NOAGGREGATION
;
878 if (!SHGetSpecialFolderPathW( 0, szMyPath
, CSIDL_DESKTOPDIRECTORY
, TRUE
))
881 sf
= LocalAlloc( LMEM_ZEROINIT
, sizeof (IGenericSFImpl
) );
883 return E_OUTOFMEMORY
;
886 sf
->lpVtbl
= &vt_MCFldr_ShellFolder2
;
887 sf
->pidlRoot
= _ILCreateDesktop(); /* my qualified pidl */
888 sf
->sPathTarget
= SHAlloc( (lstrlenW(szMyPath
) + 1)*sizeof(WCHAR
) );
889 lstrcpyW( sf
->sPathTarget
, szMyPath
);
891 r
= IUnknown_QueryInterface( _IUnknown_(sf
), riid
, ppv
);
894 IUnknown_Release( _IUnknown_(sf
) );
898 TRACE ("--(%p)\n", sf
);