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
25 WINE_DEFAULT_DEBUG_CHANNEL (shell
);
27 /***********************************************************************
28 * Desktopfolder implementation
32 const IShellFolder2Vtbl
*lpVtbl
;
33 const IPersistFolder2Vtbl
*lpPF2
;
34 const ISFHelperVtbl
*lpvtblSFHelper
;
37 /* both paths are parsible from the desktop */
38 LPWSTR sPathTarget
; /* complete path to target used for enumeration and ChangeNotify */
39 LPITEMIDLIST pidlRoot
; /* absolute pidl */
41 UINT cfShellIDList
; /* clipboardformat for IDropTarget */
42 BOOL fAcceptFmt
; /* flag for pending Drop */
43 } IGenericSFImpl
, *LPIGenericSFImpl
;
45 WCHAR
*build_paths_list(LPCWSTR wszBasePath
, int cidl
, LPCITEMIDLIST
*pidls
);
46 int SHELL_ConfirmMsgBox(HWND hWnd
, LPWSTR lpszText
, LPWSTR lpszCaption
, HICON hIcon
, BOOL bYesToAll
);
48 #define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl)
49 #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
51 static const shvheader DesktopSFHeader
[] = {
52 {IDS_SHV_COLUMN1
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 15},
53 {IDS_SHV_COLUMN2
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
54 {IDS_SHV_COLUMN3
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
55 {IDS_SHV_COLUMN4
, SHCOLSTATE_TYPE_DATE
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 12},
56 {IDS_SHV_COLUMN5
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 5}
59 #define DESKTOPSHELLVIEWCOLUMNS 5
61 /**************************************************************************
62 * ISF_Desktop_fnQueryInterface
64 * NOTES supports not IPersist/IPersistFolder
66 static HRESULT WINAPI
ISF_Desktop_fnQueryInterface(
67 IShellFolder2
* iface
, REFIID riid
, LPVOID
* ppvObj
)
69 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
71 TRACE ("(%p)->(%s,%p)\n", This
, shdebugstr_guid (riid
), ppvObj
);
75 if (IsEqualIID (riid
, &IID_IUnknown
) ||
76 IsEqualIID (riid
, &IID_IShellFolder
) ||
77 IsEqualIID (riid
, &IID_IShellFolder2
))
81 else if (IsEqualIID (riid
, &IID_IPersistFolder
) ||
82 IsEqualIID (riid
, &IID_IPersistFolder2
))
84 *ppvObj
= &This
->lpPF2
;
86 else if (IsEqualIID(riid
, &IID_ISFHelper
))
88 *ppvObj
= &This
->lpvtblSFHelper
;
92 IUnknown_AddRef ((IUnknown
*) (*ppvObj
));
93 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj
, *ppvObj
);
96 TRACE ("-- Interface: E_NOINTERFACE\n");
100 static LPIGenericSFImpl __inline
impl_from_ISFHelper( ISFHelper
*iface
)
102 return (IGenericSFImpl
*)((char*)iface
- FIELD_OFFSET(IGenericSFImpl
, lpvtblSFHelper
));
105 static ULONG WINAPI
ISF_Desktop_fnAddRef (IShellFolder2
* iface
)
107 return 2; /* non-heap based object */
110 static ULONG WINAPI
ISF_Desktop_fnRelease (IShellFolder2
* iface
)
112 return 1; /* non-heap based object */
115 /**************************************************************************
116 * ISF_Desktop_fnParseDisplayName
119 * "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds
122 static HRESULT WINAPI
ISF_Desktop_fnParseDisplayName (IShellFolder2
* iface
,
123 HWND hwndOwner
, LPBC pbc
, LPOLESTR lpszDisplayName
,
124 DWORD
* pchEaten
, LPITEMIDLIST
* ppidl
, DWORD
* pdwAttributes
)
126 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
127 WCHAR szElement
[MAX_PATH
];
128 LPCWSTR szNext
= NULL
;
129 LPITEMIDLIST pidlTemp
= NULL
;
133 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
134 This
, hwndOwner
, pbc
, lpszDisplayName
, debugstr_w(lpszDisplayName
),
135 pchEaten
, ppidl
, pdwAttributes
);
137 if (!lpszDisplayName
|| !ppidl
)
143 *pchEaten
= 0; /* strange but like the original */
145 if (lpszDisplayName
[0] == ':' && lpszDisplayName
[1] == ':')
147 szNext
= GetNextElementW (lpszDisplayName
, szElement
, MAX_PATH
);
148 TRACE ("-- element: %s\n", debugstr_w (szElement
));
149 CLSIDFromString (szElement
+ 2, &clsid
);
150 pidlTemp
= _ILCreateGuid (PT_GUID
, &clsid
);
152 else if (PathGetDriveNumberW (lpszDisplayName
) >= 0)
154 /* it's a filesystem path with a drive. Let MyComputer/UnixDosFolder parse it */
156 if (UNIXFS_is_rooted_at_desktop())
157 pidlTemp
= _ILCreateGuid(PT_GUID
, &CLSID_UnixDosFolder
);
160 pidlTemp
= _ILCreateMyComputer ();
161 szNext
= lpszDisplayName
;
163 else if (PathIsUNCW(lpszDisplayName
))
165 pidlTemp
= _ILCreateNetwork();
166 szNext
= lpszDisplayName
;
168 else if( (pidlTemp
= SHELL32_CreatePidlFromBindCtx(pbc
, lpszDisplayName
)) )
175 /* it's a filesystem path on the desktop. Let a FSFolder parse it */
177 if (*lpszDisplayName
)
179 WCHAR szPath
[MAX_PATH
];
182 /* build a complete path to create a simple pidl */
183 lstrcpynW(szPath
, This
->sPathTarget
, MAX_PATH
);
184 pathPtr
= PathAddBackslashW(szPath
);
187 lstrcpynW(pathPtr
, lpszDisplayName
, MAX_PATH
- (pathPtr
- szPath
));
188 hr
= _ILCreateFromPathW(szPath
, &pidlTemp
);
192 /* should never reach here, but for completeness */
193 hr
= HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
);
197 pidlTemp
= _ILCreateMyComputer();
202 if (SUCCEEDED(hr
) && pidlTemp
)
204 if (szNext
&& *szNext
)
206 hr
= SHELL32_ParseNextElement(iface
, hwndOwner
, pbc
,
207 &pidlTemp
, (LPOLESTR
) szNext
, pchEaten
, pdwAttributes
);
211 if (pdwAttributes
&& *pdwAttributes
)
212 hr
= SHELL32_GetItemAttributes(_IShellFolder_ (This
),
213 pidlTemp
, pdwAttributes
);
219 TRACE ("(%p)->(-- ret=0x%08x)\n", This
, hr
);
224 static const WCHAR ClassicStartMenuW
[] = {'S','O','F','T','W','A','R','E','\\',
225 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
226 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r',
227 '\\','H','i','d','e','D','e','s','k','t','o','p','I','c','o','n','s','\\',
228 'C','l','a','s','s','i','c','S','t','a','r','t','M','e','n','u','\0' };
231 IsNamespaceExtensionHidden(WCHAR
*iid
)
233 DWORD Result
, dwResult
;
234 dwResult
= sizeof(DWORD
);
236 if (RegGetValueW(HKEY_CURRENT_USER
, /* FIXME use NewStartPanel when activated */
242 &dwResult
) != ERROR_SUCCESS
)
252 SetNamespaceExtensionVisibleStatus(WCHAR
* iid
, DWORD dwStatus
)
256 if (RegOpenKeyExW(HKEY_CURRENT_USER
, ClassicStartMenuW
, 0, KEY_WRITE
, &hKey
) == ERROR_SUCCESS
)
258 RegSetValueExW(hKey
, iid
, 0, REG_DWORD
, (LPBYTE
)&dwStatus
, sizeof(DWORD
));
265 /**************************************************************************
266 * CreateDesktopEnumList()
268 static const WCHAR Desktop_NameSpaceW
[] = { 'S','O','F','T','W','A','R','E',
269 '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
270 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l',
271 'o','r','e','r','\\','D','e','s','k','t','o','p','\\','N','a','m','e','s','p',
274 static BOOL
CreateDesktopEnumList(IEnumIDList
*list
, DWORD dwFlags
)
277 WCHAR szPath
[MAX_PATH
];
279 static WCHAR MyDocumentsClassString
[] = L
"{450D8FBA-AD25-11D0-98A8-0800361B1103}";
282 TRACE("(%p)->(flags=0x%08x)\n", list
, dwFlags
);
284 /* enumerate the root folders */
285 if (dwFlags
& SHCONTF_FOLDERS
)
291 /* create the pidl for This item */
292 if (IsNamespaceExtensionHidden(MyDocumentsClassString
) < 1)
294 ret
= AddToEnumList(list
, _ILCreateMyDocuments());
296 ret
= AddToEnumList(list
, _ILCreateMyComputer());
298 for (i
= 0; i
< 2; i
++)
301 dwResult
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, Desktop_NameSpaceW
, 0, KEY_READ
, &hkey
);
303 dwResult
= RegOpenKeyExW(HKEY_CURRENT_USER
, Desktop_NameSpaceW
, 0, KEY_READ
, &hkey
);
305 if (dwResult
== ERROR_SUCCESS
)
316 size
= sizeof (iid
) / sizeof (iid
[0]);
317 r
= RegEnumKeyExW(hkey
, i
, iid
, &size
, 0, NULL
, NULL
, NULL
);
318 if (ERROR_SUCCESS
== r
)
320 if (IsNamespaceExtensionHidden(iid
) < 1)
322 pidl
= _ILCreateGuidFromStrW(iid
);
323 if (!HasItemWithCLSID(list
, pidl
))
325 ret
= AddToEnumList(list
, pidl
);
333 else if (ERROR_NO_MORE_ITEMS
== r
)
342 for (i
= 0; i
< 2; i
++)
345 dwResult
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, ClassicStartMenuW
, 0, KEY_READ
, &hkey
);
347 dwResult
= RegOpenKeyExW(HKEY_CURRENT_USER
, ClassicStartMenuW
, 0, KEY_READ
, &hkey
);
349 if (dwResult
== ERROR_SUCCESS
)
351 DWORD j
= 0, dwVal
, Val
, dwType
, dwIID
;
358 dwIID
= sizeof(iid
) / sizeof(WCHAR
);
360 r
= RegEnumValueW(hkey
, j
++, iid
, &dwIID
, NULL
, &dwType
, (LPBYTE
)&Val
, &dwVal
);
361 if (r
== ERROR_SUCCESS
)
363 if (Val
== 0 && dwType
== REG_DWORD
)
365 LPITEMIDLIST pidl
= _ILCreateGuidFromStrW(iid
);
366 if (!HasItemWithCLSID(list
, pidl
))
368 AddToEnumList(list
, pidl
);
376 else if (ERROR_NO_MORE_ITEMS
== r
)
386 /* enumerate the elements in %windir%\desktop */
387 ret
= ret
&& SHGetSpecialFolderPathW(0, szPath
, CSIDL_DESKTOPDIRECTORY
, FALSE
);
388 ret
= ret
&& CreateFolderEnumList(list
, szPath
, dwFlags
);
393 /**************************************************************************
394 * ISF_Desktop_fnEnumObjects
396 static HRESULT WINAPI
ISF_Desktop_fnEnumObjects (IShellFolder2
* iface
,
397 HWND hwndOwner
, DWORD dwFlags
, LPENUMIDLIST
* ppEnumIDList
)
399 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
401 TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n",
402 This
, hwndOwner
, dwFlags
, ppEnumIDList
);
404 *ppEnumIDList
= IEnumIDList_Constructor();
406 CreateDesktopEnumList(*ppEnumIDList
, dwFlags
);
408 TRACE ("-- (%p)->(new ID List: %p)\n", This
, *ppEnumIDList
);
410 return *ppEnumIDList
? S_OK
: E_OUTOFMEMORY
;
413 /**************************************************************************
414 * ISF_Desktop_fnBindToObject
416 static HRESULT WINAPI
ISF_Desktop_fnBindToObject (IShellFolder2
* iface
,
417 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
419 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
421 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n",
422 This
, pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
424 return SHELL32_BindToChild( This
->pidlRoot
, This
->sPathTarget
, pidl
, riid
, ppvOut
);
427 /**************************************************************************
428 * ISF_Desktop_fnBindToStorage
430 static HRESULT WINAPI
ISF_Desktop_fnBindToStorage (IShellFolder2
* iface
,
431 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
433 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
435 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n",
436 This
, pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
442 /**************************************************************************
443 * ISF_Desktop_fnCompareIDs
445 static HRESULT WINAPI
ISF_Desktop_fnCompareIDs (IShellFolder2
* iface
,
446 LPARAM lParam
, LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
448 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
451 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This
, lParam
, pidl1
, pidl2
);
452 nReturn
= SHELL32_CompareIDs (_IShellFolder_ (This
), lParam
, pidl1
, pidl2
);
453 TRACE ("-- %i\n", nReturn
);
457 /**************************************************************************
458 * ISF_Desktop_fnCreateViewObject
460 static HRESULT WINAPI
ISF_Desktop_fnCreateViewObject (IShellFolder2
* iface
,
461 HWND hwndOwner
, REFIID riid
, LPVOID
* ppvOut
)
463 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
464 LPSHELLVIEW pShellView
;
465 HRESULT hr
= E_INVALIDARG
;
467 TRACE ("(%p)->(hwnd=%p,%s,%p)\n",
468 This
, hwndOwner
, shdebugstr_guid (riid
), ppvOut
);
475 if (IsEqualIID (riid
, &IID_IDropTarget
))
477 WARN ("IDropTarget not implemented\n");
480 else if (IsEqualIID (riid
, &IID_IContextMenu
))
482 WARN ("IContextMenu not implemented\n");
485 else if (IsEqualIID (riid
, &IID_IShellView
))
487 pShellView
= IShellView_Constructor ((IShellFolder
*) iface
);
490 hr
= IShellView_QueryInterface (pShellView
, riid
, ppvOut
);
491 IShellView_Release (pShellView
);
494 TRACE ("-- (%p)->(interface=%p)\n", This
, ppvOut
);
498 /**************************************************************************
499 * ISF_Desktop_fnGetAttributesOf
501 static HRESULT WINAPI
ISF_Desktop_fnGetAttributesOf (IShellFolder2
* iface
,
502 UINT cidl
, LPCITEMIDLIST
* apidl
, DWORD
* rgfInOut
)
504 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
506 static const DWORD dwDesktopAttributes
=
507 SFGAO_STORAGE
| SFGAO_HASPROPSHEET
| SFGAO_STORAGEANCESTOR
|
508 SFGAO_FILESYSANCESTOR
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_HASSUBFOLDER
;
509 static const DWORD dwMyComputerAttributes
=
510 SFGAO_CANRENAME
| SFGAO_CANDELETE
| SFGAO_HASPROPSHEET
|
511 SFGAO_DROPTARGET
| SFGAO_FILESYSANCESTOR
| SFGAO_FOLDER
| SFGAO_HASSUBFOLDER
;
513 TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
514 This
, cidl
, apidl
, rgfInOut
, rgfInOut
? *rgfInOut
: 0);
525 *rgfInOut
&= dwDesktopAttributes
;
527 while (cidl
> 0 && *apidl
) {
529 if (_ILIsDesktop(*apidl
)) {
530 *rgfInOut
&= dwDesktopAttributes
;
531 } else if (_ILIsMyComputer(*apidl
)) {
532 *rgfInOut
&= dwMyComputerAttributes
;
534 SHELL32_GetItemAttributes (_IShellFolder_ (This
), *apidl
, rgfInOut
);
540 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
541 *rgfInOut
&= ~SFGAO_VALIDATE
;
543 TRACE ("-- result=0x%08x\n", *rgfInOut
);
548 /**************************************************************************
549 * ISF_Desktop_fnGetUIObjectOf
552 * HWND hwndOwner, //[in ] Parent window for any output
553 * UINT cidl, //[in ] array size
554 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
555 * REFIID riid, //[in ] Requested Interface
556 * UINT* prgfInOut, //[ ] reserved
557 * LPVOID* ppvObject) //[out] Resulting Interface
560 static HRESULT WINAPI
ISF_Desktop_fnGetUIObjectOf (IShellFolder2
* iface
,
561 HWND hwndOwner
, UINT cidl
, LPCITEMIDLIST
* apidl
,
562 REFIID riid
, UINT
* prgfInOut
, LPVOID
* ppvOut
)
564 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
567 IUnknown
*pObj
= NULL
;
568 HRESULT hr
= E_INVALIDARG
;
570 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
571 This
, hwndOwner
, cidl
, apidl
, shdebugstr_guid (riid
), prgfInOut
, ppvOut
);
578 if (IsEqualIID (riid
, &IID_IContextMenu
))
580 hr
= CDefFolderMenu_Create2(This
->pidlRoot
, hwndOwner
, cidl
, apidl
, (IShellFolder
*)iface
, NULL
, 0, NULL
, (IContextMenu
**)&pObj
);
582 else if (IsEqualIID (riid
, &IID_IDataObject
) && (cidl
>= 1))
584 pObj
= (LPUNKNOWN
) IDataObject_Constructor( hwndOwner
,
585 This
->pidlRoot
, apidl
, cidl
);
588 else if (IsEqualIID (riid
, &IID_IExtractIconA
) && (cidl
== 1))
590 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
591 pObj
= (LPUNKNOWN
) IExtractIconA_Constructor (pidl
);
595 else if (IsEqualIID (riid
, &IID_IExtractIconW
) && (cidl
== 1))
597 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
598 pObj
= (LPUNKNOWN
) IExtractIconW_Constructor (pidl
);
602 else if (IsEqualIID (riid
, &IID_IDropTarget
) && (cidl
>= 1))
604 hr
= IShellFolder_QueryInterface (iface
,
605 &IID_IDropTarget
, (LPVOID
*) & pObj
);
607 else if ((IsEqualIID(riid
,&IID_IShellLinkW
) ||
608 IsEqualIID(riid
,&IID_IShellLinkA
)) && (cidl
== 1))
610 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
611 hr
= IShellLink_ConstructFromFile(NULL
, riid
, pidl
, (LPVOID
*)&pObj
);
617 if (SUCCEEDED(hr
) && !pObj
)
621 TRACE ("(%p)->hr=0x%08x\n", This
, hr
);
625 /**************************************************************************
626 * ISF_Desktop_fnGetDisplayNameOf
629 * special case: pidl = null gives desktop-name back
631 static HRESULT WINAPI
ISF_Desktop_fnGetDisplayNameOf (IShellFolder2
* iface
,
632 LPCITEMIDLIST pidl
, DWORD dwFlags
, LPSTRRET strRet
)
634 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
638 TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This
, pidl
, dwFlags
, strRet
);
644 pszPath
= CoTaskMemAlloc((MAX_PATH
+1) * sizeof(WCHAR
));
646 return E_OUTOFMEMORY
;
648 if (_ILIsDesktop (pidl
))
650 if ((GET_SHGDN_RELATION (dwFlags
) == SHGDN_NORMAL
) &&
651 (GET_SHGDN_FOR (dwFlags
) & SHGDN_FORPARSING
))
652 wcscpy(pszPath
, This
->sPathTarget
);
654 HCR_GetClassNameW(&CLSID_ShellDesktop
, pszPath
, MAX_PATH
);
656 else if (_ILIsPidlSimple (pidl
))
660 if ((clsid
= _ILGetGUIDPointer (pidl
)))
662 if (GET_SHGDN_FOR (dwFlags
) & SHGDN_FORPARSING
)
664 int bWantsForParsing
;
667 * We can only get a filesystem path from a shellfolder if the
668 * value WantsFORPARSING in CLSID\\{...}\\shellfolder exists.
670 * Exception: The MyComputer folder doesn't have this key,
671 * but any other filesystem backed folder it needs it.
673 if (IsEqualIID (clsid
, &CLSID_MyComputer
))
675 bWantsForParsing
= TRUE
;
679 /* get the "WantsFORPARSING" flag from the registry */
680 static const WCHAR clsidW
[] =
681 { 'C','L','S','I','D','\\',0 };
682 static const WCHAR shellfolderW
[] =
683 { '\\','s','h','e','l','l','f','o','l','d','e','r',0 };
684 static const WCHAR wantsForParsingW
[] =
685 { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n',
687 WCHAR szRegPath
[100];
690 wcscpy (szRegPath
, clsidW
);
691 SHELL32_GUIDToStringW (clsid
, &szRegPath
[6]);
692 wcscat (szRegPath
, shellfolderW
);
693 r
= SHGetValueW(HKEY_CLASSES_ROOT
, szRegPath
,
694 wantsForParsingW
, NULL
, NULL
, NULL
);
695 if (r
== ERROR_SUCCESS
)
696 bWantsForParsing
= TRUE
;
698 bWantsForParsing
= FALSE
;
701 if ((GET_SHGDN_RELATION (dwFlags
) == SHGDN_NORMAL
) &&
705 * we need the filesystem path to the destination folder.
706 * Only the folder itself can know it
708 hr
= SHELL32_GetDisplayNameOfChild (iface
, pidl
, dwFlags
,
714 /* parsing name like ::{...} */
717 SHELL32_GUIDToStringW (clsid
, &pszPath
[2]);
722 /* user friendly name */
723 HCR_GetClassNameW (clsid
, pszPath
, MAX_PATH
);
730 /* file system folder or file rooted at the desktop */
731 if ((GET_SHGDN_FOR(dwFlags
) == SHGDN_FORPARSING
) &&
732 (GET_SHGDN_RELATION(dwFlags
) != SHGDN_INFOLDER
))
734 lstrcpynW(pszPath
, This
->sPathTarget
, MAX_PATH
- 1);
735 PathAddBackslashW(pszPath
);
736 cLen
= wcslen(pszPath
);
739 _ILSimpleGetTextW(pidl
, pszPath
+ cLen
, MAX_PATH
- cLen
);
740 if (!_ILIsFolder(pidl
))
741 SHELL_FS_ProcessDisplayFilename(pszPath
, dwFlags
);
746 /* a complex pidl, let the subfolder do the work */
747 hr
= SHELL32_GetDisplayNameOfChild (iface
, pidl
, dwFlags
,
753 /* Win9x always returns ANSI strings, NT always returns Unicode strings */
754 if (GetVersion() & 0x80000000)
756 strRet
->uType
= STRRET_CSTR
;
757 if (!WideCharToMultiByte(CP_ACP
, 0, pszPath
, -1, strRet
->u
.cStr
, MAX_PATH
,
759 strRet
->u
.cStr
[0] = '\0';
760 CoTaskMemFree(pszPath
);
764 strRet
->uType
= STRRET_WSTR
;
765 strRet
->u
.pOleStr
= pszPath
;
769 CoTaskMemFree(pszPath
);
771 TRACE ("-- (%p)->(%s,0x%08x)\n", This
,
772 strRet
->uType
== STRRET_CSTR
? strRet
->u
.cStr
:
773 debugstr_w(strRet
->u
.pOleStr
), hr
);
777 /**************************************************************************
778 * ISF_Desktop_fnSetNameOf
779 * Changes the name of a file object or subfolder, possibly changing its item
780 * identifier in the process.
783 * HWND hwndOwner, //[in ] Owner window for output
784 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
785 * LPCOLESTR lpszName, //[in ] the items new display name
786 * DWORD dwFlags, //[in ] SHGNO formatting flags
787 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
789 static HRESULT WINAPI
ISF_Desktop_fnSetNameOf (IShellFolder2
* iface
,
790 HWND hwndOwner
, LPCITEMIDLIST pidl
, /* simple pidl */
791 LPCOLESTR lpName
, DWORD dwFlags
, LPITEMIDLIST
* pPidlOut
)
793 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
796 WCHAR szSrc
[MAX_PATH
+ 1], szDest
[MAX_PATH
+ 1];
798 BOOL bIsFolder
= _ILIsFolder (ILFindLastID (pidl
));
800 TRACE ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This
, hwndOwner
, pidl
,
801 debugstr_w (lpName
), dwFlags
, pPidlOut
);
803 if (_ILGetGUIDPointer(pidl
))
805 if (SUCCEEDED(IShellFolder2_BindToObject(iface
, pidl
, NULL
, &IID_IShellFolder2
, (LPVOID
*)&psf
)))
807 hr
= IShellFolder2_SetNameOf(psf
, hwndOwner
, pidl
, lpName
, dwFlags
, pPidlOut
);
808 IShellFolder2_Release(psf
);
813 /* build source path */
814 lstrcpynW(szSrc
, This
->sPathTarget
, MAX_PATH
);
815 ptr
= PathAddBackslashW (szSrc
);
817 _ILSimpleGetTextW (pidl
, ptr
, MAX_PATH
+ 1 - (ptr
- szSrc
));
819 /* build destination path */
820 if (dwFlags
== SHGDN_NORMAL
|| dwFlags
& SHGDN_INFOLDER
) {
821 lstrcpynW(szDest
, This
->sPathTarget
, MAX_PATH
);
822 ptr
= PathAddBackslashW (szDest
);
824 lstrcpynW(ptr
, lpName
, MAX_PATH
+ 1 - (ptr
- szDest
));
826 lstrcpynW(szDest
, lpName
, MAX_PATH
);
828 if(!(dwFlags
& SHGDN_FORPARSING
) && SHELL_FS_HideExtension(szSrc
)) {
829 WCHAR
*ext
= PathFindExtensionW(szSrc
);
831 INT len
= wcslen(szDest
);
832 lstrcpynW(szDest
+ len
, ext
, MAX_PATH
- len
);
836 if (!memcmp(szSrc
, szDest
, (wcslen(szDest
)+1) * sizeof(WCHAR
)))
838 /* src and destination is the same */
841 hr
= _ILCreateFromPathW(szDest
, pPidlOut
);
846 TRACE ("src=%s dest=%s\n", debugstr_w(szSrc
), debugstr_w(szDest
));
847 if (MoveFileW (szSrc
, szDest
))
852 hr
= _ILCreateFromPathW(szDest
, pPidlOut
);
854 SHChangeNotify (bIsFolder
? SHCNE_RENAMEFOLDER
: SHCNE_RENAMEITEM
,
855 SHCNF_PATHW
, szSrc
, szDest
);
861 static HRESULT WINAPI
ISF_Desktop_fnGetDefaultSearchGUID(IShellFolder2
*iface
,
864 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
866 FIXME ("(%p)\n", This
);
870 static HRESULT WINAPI
ISF_Desktop_fnEnumSearches (IShellFolder2
*iface
,
871 IEnumExtraSearch
** ppenum
)
873 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
874 FIXME ("(%p)\n", This
);
878 static HRESULT WINAPI
ISF_Desktop_fnGetDefaultColumn (IShellFolder2
* iface
,
879 DWORD dwRes
, ULONG
* pSort
, ULONG
* pDisplay
)
881 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
883 TRACE ("(%p)\n", This
);
892 static HRESULT WINAPI
ISF_Desktop_fnGetDefaultColumnState (
893 IShellFolder2
* iface
, UINT iColumn
, DWORD
* pcsFlags
)
895 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
897 TRACE ("(%p)\n", This
);
899 if (!pcsFlags
|| iColumn
>= DESKTOPSHELLVIEWCOLUMNS
)
902 *pcsFlags
= DesktopSFHeader
[iColumn
].pcsFlags
;
907 static HRESULT WINAPI
ISF_Desktop_fnGetDetailsEx (IShellFolder2
* iface
,
908 LPCITEMIDLIST pidl
, const SHCOLUMNID
* pscid
, VARIANT
* pv
)
910 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
911 FIXME ("(%p)\n", This
);
916 static HRESULT WINAPI
ISF_Desktop_fnGetDetailsOf (IShellFolder2
* iface
,
917 LPCITEMIDLIST pidl
, UINT iColumn
, SHELLDETAILS
* psd
)
919 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
923 TRACE ("(%p)->(%p %i %p)\n", This
, pidl
, iColumn
, psd
);
925 if (!psd
|| iColumn
>= DESKTOPSHELLVIEWCOLUMNS
)
930 psd
->fmt
= DesktopSFHeader
[iColumn
].fmt
;
931 psd
->cxChar
= DesktopSFHeader
[iColumn
].cxChar
;
932 psd
->str
.uType
= STRRET_CSTR
;
933 LoadStringA (shell32_hInstance
, DesktopSFHeader
[iColumn
].colnameid
,
934 psd
->str
.u
.cStr
, MAX_PATH
);
938 /* the data from the pidl */
939 psd
->str
.uType
= STRRET_CSTR
;
943 hr
= IShellFolder_GetDisplayNameOf(iface
, pidl
,
944 SHGDN_NORMAL
| SHGDN_INFOLDER
, &psd
->str
);
947 _ILGetFileSize (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
950 _ILGetFileType (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
953 _ILGetFileDate (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
955 case 4: /* attributes */
956 _ILGetFileAttributes (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
963 static HRESULT WINAPI
ISF_Desktop_fnMapColumnToSCID (
964 IShellFolder2
* iface
, UINT column
, SHCOLUMNID
* pscid
)
966 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
967 FIXME ("(%p)\n", This
);
971 static const IShellFolder2Vtbl vt_MCFldr_ShellFolder2
=
973 ISF_Desktop_fnQueryInterface
,
974 ISF_Desktop_fnAddRef
,
975 ISF_Desktop_fnRelease
,
976 ISF_Desktop_fnParseDisplayName
,
977 ISF_Desktop_fnEnumObjects
,
978 ISF_Desktop_fnBindToObject
,
979 ISF_Desktop_fnBindToStorage
,
980 ISF_Desktop_fnCompareIDs
,
981 ISF_Desktop_fnCreateViewObject
,
982 ISF_Desktop_fnGetAttributesOf
,
983 ISF_Desktop_fnGetUIObjectOf
,
984 ISF_Desktop_fnGetDisplayNameOf
,
985 ISF_Desktop_fnSetNameOf
,
987 ISF_Desktop_fnGetDefaultSearchGUID
,
988 ISF_Desktop_fnEnumSearches
,
989 ISF_Desktop_fnGetDefaultColumn
,
990 ISF_Desktop_fnGetDefaultColumnState
,
991 ISF_Desktop_fnGetDetailsEx
,
992 ISF_Desktop_fnGetDetailsOf
,
993 ISF_Desktop_fnMapColumnToSCID
996 static LPIGenericSFImpl __inline
impl_from_IPersistFolder2( IPersistFolder2
*iface
)
998 return (IGenericSFImpl
*)((char*)iface
- FIELD_OFFSET(IGenericSFImpl
, lpPF2
));
1001 static HRESULT WINAPI
1002 ISF_Desktop_PersistFolder2_fnQueryInterface (IPersistFolder2
* iface
, REFIID iid
,
1005 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
1007 TRACE ("(%p)\n", This
);
1009 return ISF_Desktop_fnQueryInterface ((IShellFolder2
*)This
, iid
, ppvObj
);
1013 ISF_Desktop_PersistFolder2_fnAddRef (IPersistFolder2
* iface
)
1015 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
1017 TRACE ("(%p)->(count=%u)\n", This
, This
->ref
);
1019 return ISF_Desktop_fnAddRef((IShellFolder2
*)This
);
1023 ISF_Desktop_PersistFolder2_fnRelease (IPersistFolder2
* iface
)
1025 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
1027 TRACE ("(%p)->(count=%u)\n", This
, This
->ref
);
1029 return ISF_Desktop_fnRelease ((IShellFolder2
*)This
);
1032 static HRESULT WINAPI
1033 ISF_Desktop_PersistFolder2_fnGetClassID (IPersistFolder2
* iface
, CLSID
* lpClassId
)
1035 static GUID
const CLSID_Desktop
=
1036 { 0x00021400, 0x0000, 0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46} };
1038 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
1040 TRACE ("(%p)\n", This
);
1045 memcpy(lpClassId
, &CLSID_Desktop
, sizeof(GUID
));
1049 static HRESULT WINAPI
1050 ISF_Desktop_PersistFolder2_fnInitialize (IPersistFolder2
* iface
, LPCITEMIDLIST pidl
)
1052 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
1054 TRACE ("(%p)->(%p)\n", This
, pidl
);
1059 static HRESULT WINAPI
1060 ISF_Desktop_PersistFolder2_fnGetCurFolder (IPersistFolder2
* iface
,
1061 LPITEMIDLIST
* pidl
)
1063 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
1065 TRACE ("(%p)->(%p)\n", This
, pidl
);
1067 if (!pidl
) return E_POINTER
;
1068 *pidl
= ILClone (This
->pidlRoot
);
1072 static const IPersistFolder2Vtbl vt_FSFldr_PersistFolder2
=
1074 ISF_Desktop_PersistFolder2_fnQueryInterface
,
1075 ISF_Desktop_PersistFolder2_fnAddRef
,
1076 ISF_Desktop_PersistFolder2_fnRelease
,
1077 ISF_Desktop_PersistFolder2_fnGetClassID
,
1078 ISF_Desktop_PersistFolder2_fnInitialize
,
1079 ISF_Desktop_PersistFolder2_fnGetCurFolder
,
1082 static HRESULT WINAPI
1083 ISF_Desktop_ISFHelper_fnQueryInterface (ISFHelper
* iface
, REFIID riid
, LPVOID
* ppvObj
)
1085 IGenericSFImpl
*This
= impl_from_ISFHelper(iface
);
1087 TRACE ("(%p)->(count=%u)\n", This
, This
->ref
);
1089 return ISF_Desktop_fnQueryInterface ((IShellFolder2
*)This
, riid
, ppvObj
);
1093 ISF_Desktop_ISFHelper_fnAddRef (ISFHelper
* iface
)
1095 IGenericSFImpl
*This
= impl_from_ISFHelper(iface
);
1097 TRACE ("(%p)->(count=%u)\n", This
, This
->ref
);
1099 return ISF_Desktop_fnAddRef((IShellFolder2
*)This
);
1103 ISF_Desktop_ISFHelper_fnRelease (ISFHelper
* iface
)
1105 IGenericSFImpl
*This
= impl_from_ISFHelper(iface
);
1107 TRACE ("(%p)\n", This
);
1109 return ISF_Desktop_fnRelease ((IShellFolder2
*)This
);
1112 static HRESULT WINAPI
1113 ISF_Desktop_ISFHelper_fnGetUniqueName (ISFHelper
* iface
, LPWSTR pwszName
, UINT uLen
)
1115 IGenericSFImpl
*This
= impl_from_ISFHelper(iface
);
1118 WCHAR wszText
[MAX_PATH
];
1119 WCHAR wszNewFolder
[25];
1120 const WCHAR wszFormat
[] = {'%','s',' ','%','d',0 };
1122 LoadStringW(shell32_hInstance
, IDS_NEWFOLDER
, wszNewFolder
, sizeof(wszNewFolder
)/sizeof(WCHAR
));
1124 TRACE ("(%p)(%p %u)\n", This
, pwszName
, uLen
);
1126 if (uLen
< sizeof(wszNewFolder
)/sizeof(WCHAR
) + 3)
1129 lstrcpynW (pwszName
, wszNewFolder
, uLen
);
1131 hr
= IShellFolder_EnumObjects ((IShellFolder2
*)This
, 0,
1132 SHCONTF_FOLDERS
| SHCONTF_NONFOLDERS
| SHCONTF_INCLUDEHIDDEN
, &penum
);
1139 IEnumIDList_Reset (penum
);
1140 while (S_OK
== IEnumIDList_Next (penum
, 1, &pidl
, &dwFetched
) &&
1142 _ILSimpleGetTextW (pidl
, wszText
, MAX_PATH
);
1143 if (0 == lstrcmpiW (wszText
, pwszName
)) {
1144 _snwprintf (pwszName
, uLen
, wszFormat
, wszNewFolder
, i
++);
1153 IEnumIDList_Release (penum
);
1158 static HRESULT WINAPI
1159 ISF_Desktop_ISFHelper_fnAddFolder (ISFHelper
* iface
, HWND hwnd
, LPCWSTR pwszName
,
1160 LPITEMIDLIST
* ppidlOut
)
1162 IGenericSFImpl
*This
= impl_from_ISFHelper(iface
);
1163 WCHAR wszNewDir
[MAX_PATH
];
1165 HRESULT hres
= E_FAIL
;
1167 TRACE ("(%p)(%s %p)\n", This
, debugstr_w(pwszName
), ppidlOut
);
1170 if (This
->sPathTarget
)
1171 lstrcpynW(wszNewDir
, This
->sPathTarget
, MAX_PATH
);
1172 PathAppendW(wszNewDir
, pwszName
);
1173 bRes
= CreateDirectoryW (wszNewDir
, NULL
);
1176 SHChangeNotify (SHCNE_MKDIR
, SHCNF_PATHW
, wszNewDir
, NULL
);
1179 hres
= _ILCreateFromPathW(wszNewDir
, ppidlOut
);
1184 static HRESULT WINAPI
1185 ISF_Desktop_ISFHelper_fnDeleteItems (ISFHelper
* iface
, UINT cidl
, LPCITEMIDLIST
* apidl
)
1187 IGenericSFImpl
*This
= impl_from_ISFHelper(iface
);
1190 WCHAR wszPath
[MAX_PATH
];
1191 WCHAR wszCaption
[50];
1192 WCHAR
*wszPathsList
;
1194 WCHAR
*wszCurrentPath
;
1195 UINT bRestoreWithDeskCpl
= FALSE
;
1198 TRACE ("(%p)(%u %p)\n", This
, cidl
, apidl
);
1199 if (cidl
==0) return S_OK
;
1201 for(i
= 0; i
< cidl
; i
++)
1203 if (_ILIsMyComputer(apidl
[i
]))
1204 bRestoreWithDeskCpl
++;
1205 else if (_ILIsNetHood(apidl
[i
]))
1206 bRestoreWithDeskCpl
++;
1207 else if (_ILIsMyDocuments(apidl
[i
]))
1208 bRestoreWithDeskCpl
++;
1211 if (bRestoreWithDeskCpl
)
1213 /* FIXME use FormatMessage
1214 * use a similar message resource as in windows
1216 LoadStringW(shell32_hInstance
, IDS_DELETEMULTIPLE_TEXT
, wszPath
, sizeof(wszPath
)/sizeof(WCHAR
));
1217 wszPath
[(sizeof(wszPath
)/sizeof(WCHAR
))-1] = 0;
1219 LoadStringW(shell32_hInstance
, IDS_DELETEITEM_CAPTION
, wszCaption
, sizeof(wszCaption
)/sizeof(WCHAR
));
1220 wszCaption
[(sizeof(wszCaption
)/sizeof(WCHAR
))-1] = 0;
1222 res
= SHELL_ConfirmMsgBox(GetActiveWindow(), wszPath
, wszCaption
, NULL
, cidl
> 1);
1223 if (res
== IDD_YESTOALL
|| res
== IDYES
)
1225 for(i
= 0; i
< cidl
; i
++)
1227 if (_ILIsMyComputer(apidl
[i
]))
1228 SetNamespaceExtensionVisibleStatus(L
"{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 0x1);
1229 else if (_ILIsNetHood(apidl
[i
]))
1230 SetNamespaceExtensionVisibleStatus(L
"{208D2C60-3AEA-1069-A2D7-08002B30309D}", 0x1);
1231 else if (_ILIsMyDocuments(apidl
[i
]))
1232 SetNamespaceExtensionVisibleStatus(L
"{450D8FBA-AD25-11D0-98A8-0800361B1103}", 0x1);
1236 if (This
->sPathTarget
)
1237 lstrcpynW(wszPath
, This
->sPathTarget
, MAX_PATH
);
1241 PathAddBackslashW(wszPath
);
1242 wszPathsList
= build_paths_list(wszPath
, cidl
, apidl
);
1244 ZeroMemory(&op
, sizeof(op
));
1245 op
.hwnd
= GetActiveWindow();
1246 op
.wFunc
= FO_DELETE
;
1247 op
.pFrom
= wszPathsList
;
1248 op
.fFlags
= FOF_ALLOWUNDO
;
1249 if (SHFileOperationW(&op
))
1251 WARN("SHFileOperation failed\n");
1257 /* we currently need to manually send the notifies */
1258 wszCurrentPath
= wszPathsList
;
1259 for (i
= 0; i
< cidl
; i
++)
1263 if (_ILIsFolder(apidl
[i
]))
1264 wEventId
= SHCNE_RMDIR
;
1265 else if (_ILIsValue(apidl
[i
]))
1266 wEventId
= SHCNE_DELETE
;
1270 /* check if file exists */
1271 if (GetFileAttributesW(wszCurrentPath
) == INVALID_FILE_ATTRIBUTES
)
1273 LPITEMIDLIST pidl
= ILCombine(This
->pidlRoot
, apidl
[i
]);
1274 SHChangeNotify(wEventId
, SHCNF_IDLIST
, pidl
, NULL
);
1278 wszCurrentPath
+= wcslen(wszCurrentPath
)+1;
1280 HeapFree(GetProcessHeap(), 0, wszPathsList
);
1284 static HRESULT WINAPI
1285 ISF_Desktop_ISFHelper_fnCopyItems (ISFHelper
* iface
, IShellFolder
* pSFFrom
, UINT cidl
, LPCITEMIDLIST
* apidl
)
1287 IPersistFolder2
*ppf2
= NULL
;
1288 WCHAR szSrcPath
[MAX_PATH
];
1289 WCHAR szTargetPath
[MAX_PATH
];
1292 LPWSTR pszSrc
, pszTarget
, pszSrcList
, pszTargetList
;
1295 IGenericSFImpl
*This
= impl_from_ISFHelper(iface
);
1297 TRACE ("(%p)->(%p,%u,%p)\n", This
, pSFFrom
, cidl
, apidl
);
1299 IShellFolder_QueryInterface (pSFFrom
, &IID_IPersistFolder2
, (LPVOID
*) & ppf2
);
1302 if (FAILED(IPersistFolder2_GetCurFolder (ppf2
, &pidl
)))
1304 IPersistFolder2_Release(ppf2
);
1307 IPersistFolder2_Release(ppf2
);
1309 if (FAILED(IShellFolder_GetDisplayNameOf(pSFFrom
, pidl
, SHGDN_FORPARSING
, &strRet
)))
1315 if (FAILED(StrRetToBufW(&strRet
, pidl
, szSrcPath
, MAX_PATH
)))
1322 pszSrc
= PathAddBackslashW (szSrcPath
);
1324 wcscpy(szTargetPath
, This
->sPathTarget
);
1325 pszTarget
= PathAddBackslashW (szTargetPath
);
1327 pszSrcList
= build_paths_list(szSrcPath
, cidl
, apidl
);
1328 pszTargetList
= build_paths_list(szTargetPath
, cidl
, apidl
);
1330 if (!pszSrcList
|| !pszTargetList
)
1333 HeapFree(GetProcessHeap(), 0, pszSrcList
);
1336 HeapFree(GetProcessHeap(), 0, pszTargetList
);
1339 IPersistFolder2_Release (ppf2
);
1340 return E_OUTOFMEMORY
;
1342 ZeroMemory(&op
, sizeof(op
));
1345 /* remove trailing backslash */
1348 op
.pFrom
= szSrcPath
;
1352 op
.pFrom
= pszSrcList
;
1355 if (!pszTargetList
[0])
1357 /* remove trailing backslash */
1358 if (pszTarget
- szTargetPath
> 3)
1361 pszTarget
[0] = L
'\0';
1365 pszTarget
[1] = L
'\0';
1368 op
.pTo
= szTargetPath
;
1372 op
.pTo
= pszTargetList
;
1374 op
.hwnd
= GetActiveWindow();
1376 op
.fFlags
= FOF_ALLOWUNDO
| FOF_NOCONFIRMMKDIR
;
1378 res
= SHFileOperationW(&op
);
1380 HeapFree(GetProcessHeap(), 0, pszSrc
);
1381 HeapFree(GetProcessHeap(), 0, pszTarget
);
1391 static const ISFHelperVtbl vt_FSFldr_ISFHelper
=
1393 ISF_Desktop_ISFHelper_fnQueryInterface
,
1394 ISF_Desktop_ISFHelper_fnAddRef
,
1395 ISF_Desktop_ISFHelper_fnRelease
,
1396 ISF_Desktop_ISFHelper_fnGetUniqueName
,
1397 ISF_Desktop_ISFHelper_fnAddFolder
,
1398 ISF_Desktop_ISFHelper_fnDeleteItems
,
1399 ISF_Desktop_ISFHelper_fnCopyItems
1403 /**************************************************************************
1404 * ISF_Desktop_Constructor
1406 HRESULT WINAPI
ISF_Desktop_Constructor (
1407 IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
1409 static IGenericSFImpl
*cached_sf
;
1410 WCHAR szMyPath
[MAX_PATH
];
1412 TRACE ("unkOut=%p %s\n", pUnkOuter
, shdebugstr_guid (riid
));
1417 return CLASS_E_NOAGGREGATION
;
1423 if (!SHGetSpecialFolderPathW( 0, szMyPath
, CSIDL_DESKTOPDIRECTORY
, TRUE
))
1424 return E_UNEXPECTED
;
1426 sf
= LocalAlloc( LMEM_ZEROINIT
, sizeof (IGenericSFImpl
) );
1428 return E_OUTOFMEMORY
;
1431 sf
->lpVtbl
= &vt_MCFldr_ShellFolder2
;
1432 sf
->lpPF2
= &vt_FSFldr_PersistFolder2
;
1433 sf
->lpvtblSFHelper
= &vt_FSFldr_ISFHelper
;
1434 sf
->pidlRoot
= _ILCreateDesktop(); /* my qualified pidl */
1435 sf
->sPathTarget
= SHAlloc( (wcslen(szMyPath
) + 1)*sizeof(WCHAR
) );
1436 wcscpy( sf
->sPathTarget
, szMyPath
);
1438 if (InterlockedCompareExchangePointer((void *)&cached_sf
, sf
, NULL
) != NULL
)
1440 /* some other thread already been here */
1441 SHFree( sf
->pidlRoot
);
1442 SHFree( sf
->sPathTarget
);
1447 return IUnknown_QueryInterface( _IUnknown_(cached_sf
), riid
, ppv
);