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 * IShellFolder implementation
65 IShellFolder2Vtbl
*lpvtblShellFolder
;
66 IPersistFolder3Vtbl
*lpvtblPersistFolder3
;
67 IDropTargetVtbl
*lpvtblDropTarget
;
68 ISFHelperVtbl
*lpvtblSFHelper
;
70 IUnknown
*pUnkOuter
; /* used for aggregation */
74 /* both paths are parsible from the desktop */
75 LPSTR sPathTarget
; /* complete path to target used for enumeration and ChangeNotify */
77 LPITEMIDLIST pidlRoot
; /* absolute pidl */
79 int dwAttributes
; /* attributes returned by GetAttributesOf FIXME: use it */
81 UINT cfShellIDList
; /* clipboardformat for IDropTarget */
82 BOOL fAcceptFmt
; /* flag for pending Drop */
85 static struct IUnknownVtbl unkvt
;
86 static struct IShellFolder2Vtbl sfvt
;
87 static struct IPersistFolder3Vtbl vt_FSFldr_PersistFolder3
; /* IPersistFolder3 for a FS_Folder */
88 static struct IDropTargetVtbl dtvt
;
89 static struct ISFHelperVtbl shvt
;
91 #define _IShellFolder2_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblShellFolder)))
92 #define _ICOM_THIS_From_IShellFolder2(class, name) class* This = (class*)(((char*)name)-_IShellFolder2_Offset);
94 #define _IPersistFolder2_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblPersistFolder3)))
95 #define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder2_Offset);
97 #define _IPersistFolder3_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblPersistFolder3)))
98 #define _ICOM_THIS_From_IPersistFolder3(class, name) class* This = (class*)(((char*)name)-_IPersistFolder3_Offset);
100 #define _IDropTarget_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblDropTarget)))
101 #define _ICOM_THIS_From_IDropTarget(class, name) class* This = (class*)(((char*)name)-_IDropTarget_Offset);
103 #define _ISFHelper_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblSFHelper)))
104 #define _ICOM_THIS_From_ISFHelper(class, name) class* This = (class*)(((char*)name)-_ISFHelper_Offset);
107 converts This to an interface pointer
109 #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl)
110 #define _IShellFolder_(This) (IShellFolder*)&(This->lpvtblShellFolder)
111 #define _IShellFolder2_(This) (IShellFolder2*)&(This->lpvtblShellFolder)
112 #define _IPersist_(This) (IPersist*)&(This->lpvtblPersistFolder3)
113 #define _IPersistFolder_(This) (IPersistFolder*)&(This->lpvtblPersistFolder3)
114 #define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpvtblPersistFolder3)
115 #define _IPersistFolder3_(This) (IPersistFolder3*)&(This->lpvtblPersistFolder3)
116 #define _IDropTarget_(This) (IDropTarget*)&(This->lpvtblDropTarget)
117 #define _ISFHelper_(This) (ISFHelper*)&(This->lpvtblSFHelper)
119 /**************************************************************************
120 * registers clipboardformat once
122 static void SF_RegisterClipFmt (IGenericSFImpl
* This
)
124 TRACE ("(%p)\n", This
);
126 if (!This
->cfShellIDList
) {
127 This
->cfShellIDList
= RegisterClipboardFormatA (CFSTR_SHELLIDLIST
);
131 /**************************************************************************
132 * we need a separate IUnknown to handle aggregation
135 static HRESULT WINAPI
IUnknown_fnQueryInterface (IUnknown
* iface
, REFIID riid
, LPVOID
* ppvObj
)
137 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
139 TRACE ("(%p)->(%s,%p)\n", This
, shdebugstr_guid (riid
), ppvObj
);
143 if (IsEqualIID (riid
, &IID_IUnknown
))
144 *ppvObj
= _IUnknown_ (This
);
145 else if (IsEqualIID (riid
, &IID_IShellFolder
))
146 *ppvObj
= _IShellFolder_ (This
);
147 else if (IsEqualIID (riid
, &IID_IShellFolder2
))
148 *ppvObj
= _IShellFolder_ (This
);
149 else if (IsEqualIID (riid
, &IID_IPersist
))
150 *ppvObj
= _IPersist_ (This
);
151 else if (IsEqualIID (riid
, &IID_IPersistFolder
))
152 *ppvObj
= _IPersistFolder_ (This
);
153 else if (IsEqualIID (riid
, &IID_IPersistFolder2
))
154 *ppvObj
= _IPersistFolder2_ (This
);
155 else if (IsEqualIID (riid
, &IID_IPersistFolder3
))
156 *ppvObj
= _IPersistFolder3_ (This
);
157 else if (IsEqualIID (riid
, &IID_ISFHelper
))
158 *ppvObj
= _ISFHelper_ (This
);
159 else if (IsEqualIID (riid
, &IID_IDropTarget
)) {
160 *ppvObj
= _IDropTarget_ (This
);
161 SF_RegisterClipFmt (This
);
165 IUnknown_AddRef ((IUnknown
*) (*ppvObj
));
166 TRACE ("-- Interface = %p\n", *ppvObj
);
169 TRACE ("-- Interface: E_NOINTERFACE\n");
170 return E_NOINTERFACE
;
173 static ULONG WINAPI
IUnknown_fnAddRef (IUnknown
* iface
)
175 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
176 ULONG refCount
= InterlockedIncrement(&This
->ref
);
178 TRACE ("(%p)->(count=%lu)\n", This
, refCount
- 1);
183 static ULONG WINAPI
IUnknown_fnRelease (IUnknown
* iface
)
185 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
186 ULONG refCount
= InterlockedDecrement(&This
->ref
);
188 TRACE ("(%p)->(count=%lu)\n", This
, refCount
+ 1);
191 TRACE ("-- destroying IShellFolder(%p)\n", This
);
194 SHFree (This
->pidlRoot
);
195 if (This
->sPathTarget
)
196 SHFree (This
->sPathTarget
);
197 LocalFree ((HLOCAL
) This
);
202 static IUnknownVtbl unkvt
=
204 IUnknown_fnQueryInterface
,
209 static shvheader GenericSFHeader
[] = {
210 {IDS_SHV_COLUMN1
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 15},
211 {IDS_SHV_COLUMN2
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
212 {IDS_SHV_COLUMN3
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
213 {IDS_SHV_COLUMN4
, SHCOLSTATE_TYPE_DATE
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 12},
214 {IDS_SHV_COLUMN5
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 5}
217 #define GENERICSHELLVIEWCOLUMNS 5
219 /**************************************************************************
220 * IFSFolder_Constructor
223 * creating undocumented ShellFS_Folder as part of an aggregation
224 * {F3364BA0-65B9-11CE-A9BA-00AA004AE837}
228 IFSFolder_Constructor (IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
232 TRACE ("unkOut=%p %s\n", pUnkOuter
, shdebugstr_guid (riid
));
234 if (pUnkOuter
&& !IsEqualIID (riid
, &IID_IUnknown
))
235 return CLASS_E_NOAGGREGATION
;
236 sf
= (IGenericSFImpl
*) LocalAlloc (LMEM_ZEROINIT
, sizeof (IGenericSFImpl
));
238 return E_OUTOFMEMORY
;
242 sf
->lpvtblShellFolder
= &sfvt
;
243 sf
->lpvtblPersistFolder3
= &vt_FSFldr_PersistFolder3
;
244 sf
->lpvtblDropTarget
= &dtvt
;
245 sf
->lpvtblSFHelper
= &shvt
;
246 sf
->pclsid
= (CLSID
*) & CLSID_ShellFSFolder
;
247 sf
->pUnkOuter
= pUnkOuter
? pUnkOuter
: _IUnknown_ (sf
);
249 if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf
), riid
, ppv
))) {
250 IUnknown_Release (_IUnknown_ (sf
));
251 return E_NOINTERFACE
;
254 TRACE ("--%p\n", *ppv
);
258 /**************************************************************************
259 * IShellFolder_fnQueryInterface
262 * REFIID riid [in ] Requested InterfaceID
263 * LPVOID* ppvObject [out] Interface* to hold the result
265 static HRESULT WINAPI
266 IShellFolder_fnQueryInterface (IShellFolder2
* iface
, REFIID riid
,
269 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
271 TRACE ("(%p)->(%s,%p)\n", This
, shdebugstr_guid (riid
), ppvObj
);
273 return IUnknown_QueryInterface (This
->pUnkOuter
, riid
, ppvObj
);
276 /**************************************************************************
277 * IShellFolder_AddRef
280 static ULONG WINAPI
IShellFolder_fnAddRef (IShellFolder2
* iface
)
282 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
284 TRACE ("(%p)->(count=%lu)\n", This
, This
->ref
);
286 return IUnknown_AddRef (This
->pUnkOuter
);
289 /**************************************************************************
290 * IShellFolder_fnRelease
292 static ULONG WINAPI
IShellFolder_fnRelease (IShellFolder2
* iface
)
294 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
296 TRACE ("(%p)->(count=%lu)\n", This
, This
->ref
);
298 return IUnknown_Release (This
->pUnkOuter
);
301 /**************************************************************************
302 * SHELL32_CreatePidlFromBindCtx [internal]
304 * If the caller bound File System Bind Data, assume it is the
305 * find data for the path.
306 * This allows binding of paths that don't exist.
308 LPITEMIDLIST
SHELL32_CreatePidlFromBindCtx(IBindCtx
*pbc
, LPCWSTR path
)
310 static const WCHAR szfsbc
[] = {
311 'F','i','l','e',' ','S','y','s','t','e','m',' ',
312 'B','i','n','d',' ','D','a','t','a',0 };
313 IFileSystemBindData
*fsbd
= NULL
;
314 LPITEMIDLIST pidl
= NULL
;
315 IUnknown
*param
= NULL
;
316 WIN32_FIND_DATAW wfd
;
319 TRACE("%p %s\n", pbc
, debugstr_w(path
));
324 /* see if the caller bound File System Bind Data */
325 r
= IBindCtx_GetObjectParam( pbc
, (LPOLESTR
) szfsbc
, ¶m
);
329 r
= IUnknown_QueryInterface( param
, &IID_IFileSystemBindData
,
333 r
= IFileSystemBindData_GetFindData( fsbd
, &wfd
);
336 lstrcpynW( &wfd
.cFileName
[0], path
, MAX_PATH
);
337 pidl
= _ILCreateFromFindDataW( &wfd
);
339 IFileSystemBindData_Release( fsbd
);
345 /**************************************************************************
346 * IShellFolder_ParseDisplayName {SHELL32}
348 * Parse a display name.
351 * hwndOwner [in] Parent window for any message's
352 * pbc [in] optional FileSystemBindData context
353 * lpszDisplayName [in] Unicode displayname.
354 * pchEaten [out] (unicode) characters processed
355 * ppidl [out] complex pidl to item
356 * pdwAttributes [out] items attributes
359 * Every folder tries to parse only its own (the leftmost) pidl and creates a
360 * subfolder to evaluate the remaining parts.
361 * Now we can parse into namespaces implemented by shell extensions
363 * Behaviour on win98: lpszDisplayName=NULL -> crash
364 * lpszDisplayName="" -> returns mycoputer-pidl
367 * pdwAttributes is not set
368 * pchEaten is not set like in windows
370 static HRESULT WINAPI
371 IShellFolder_fnParseDisplayName (IShellFolder2
* iface
,
374 LPOLESTR lpszDisplayName
,
375 DWORD
* pchEaten
, LPITEMIDLIST
* ppidl
,
376 DWORD
* pdwAttributes
)
378 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
380 HRESULT hr
= E_INVALIDARG
;
381 LPCWSTR szNext
= NULL
;
382 WCHAR szElement
[MAX_PATH
];
383 WCHAR szPath
[MAX_PATH
];
384 LPITEMIDLIST pidlTemp
= NULL
;
387 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
388 This
, hwndOwner
, pbc
, lpszDisplayName
, debugstr_w (lpszDisplayName
),
389 pchEaten
, ppidl
, pdwAttributes
);
391 if (!lpszDisplayName
|| !ppidl
)
395 *pchEaten
= 0; /* strange but like the original */
397 pidlTemp
= SHELL32_CreatePidlFromBindCtx(pbc
, lpszDisplayName
);
398 if (!pidlTemp
&& *lpszDisplayName
)
400 /* get the next element */
401 szNext
= GetNextElementW (lpszDisplayName
, szElement
, MAX_PATH
);
403 /* build the full pathname to the element */
404 /* lstrcpyW(szPath, This->sPathTarget); */
405 MultiByteToWideChar(CP_ACP
, 0, This
->sPathTarget
, -1, szPath
, MAX_PATH
);
406 PathAddBackslashW(szPath
);
407 len
= lstrlenW(szPath
);
408 lstrcpynW(szPath
+ len
, szElement
, MAX_PATH
- len
);
411 hr
= _ILCreateFromPathW(szPath
, &pidlTemp
);
414 if (szNext
&& *szNext
) {
415 /* try to analyse the next element */
416 hr
= SHELL32_ParseNextElement (iface
, hwndOwner
, pbc
,
417 &pidlTemp
, (LPOLESTR
) szNext
, pchEaten
, pdwAttributes
);
419 /* it's the last element */
420 if (pdwAttributes
&& *pdwAttributes
) {
421 hr
= SHELL32_GetItemAttributes (_IShellFolder_ (This
),
422 pidlTemp
, pdwAttributes
);
433 TRACE ("(%p)->(-- pidl=%p ret=0x%08lx)\n", This
, ppidl
? *ppidl
: 0, hr
);
438 /**************************************************************************
439 * IShellFolder_fnEnumObjects
441 * HWND hwndOwner, //[in ] Parent Window
442 * DWORD grfFlags, //[in ] SHCONTF enumeration mask
443 * LPENUMIDLIST* ppenumIDList //[out] IEnumIDList interface
445 static HRESULT WINAPI
446 IShellFolder_fnEnumObjects (IShellFolder2
* iface
, HWND hwndOwner
,
447 DWORD dwFlags
, LPENUMIDLIST
* ppEnumIDList
)
449 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
451 TRACE ("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This
, hwndOwner
,
452 dwFlags
, ppEnumIDList
);
454 *ppEnumIDList
= IEnumIDList_Constructor();
457 WCHAR path
[MAX_PATH
];
458 MultiByteToWideChar(CP_ACP
, 0, This
->sPathTarget
, -1, path
, MAX_PATH
);
459 CreateFolderEnumList(*ppEnumIDList
, path
, dwFlags
);
462 TRACE ("-- (%p)->(new ID List: %p)\n", This
, *ppEnumIDList
);
464 return *ppEnumIDList
? S_OK
: E_OUTOFMEMORY
;
467 /**************************************************************************
468 * IShellFolder_fnBindToObject
470 * LPCITEMIDLIST pidl, //[in ] relative pidl to open
471 * LPBC pbc, //[in ] optional FileSystemBindData context
472 * REFIID riid, //[in ] Initial Interface
473 * LPVOID* ppvObject //[out] Interface*
475 static HRESULT WINAPI
476 IShellFolder_fnBindToObject (IShellFolder2
* iface
, LPCITEMIDLIST pidl
,
477 LPBC pbc
, REFIID riid
, LPVOID
* ppvOut
)
479 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
481 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This
, pidl
, pbc
,
482 shdebugstr_guid (riid
), ppvOut
);
484 return SHELL32_BindToChild (This
->pidlRoot
, This
->sPathTarget
, pidl
, riid
,
488 /**************************************************************************
489 * IShellFolder_fnBindToStorage
491 * LPCITEMIDLIST pidl, //[in ] complex pidl to store
492 * LPBC pbc, //[in ] reserved
493 * REFIID riid, //[in ] Initial storage interface
494 * LPVOID* ppvObject //[out] Interface* returned
496 static HRESULT WINAPI
497 IShellFolder_fnBindToStorage (IShellFolder2
* iface
, LPCITEMIDLIST pidl
,
498 LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
500 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
502 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This
, pidl
, pbcReserved
,
503 shdebugstr_guid (riid
), ppvOut
);
509 /**************************************************************************
510 * IShellFolder_fnCompareIDs
513 static HRESULT WINAPI
514 IShellFolder_fnCompareIDs (IShellFolder2
* iface
, LPARAM lParam
,
515 LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
517 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
521 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This
, lParam
, pidl1
, pidl2
);
522 nReturn
= SHELL32_CompareIDs (_IShellFolder_ (This
), lParam
, pidl1
, pidl2
);
523 TRACE ("-- %i\n", nReturn
);
527 /**************************************************************************
528 * IShellFolder_fnCreateViewObject
530 static HRESULT WINAPI
531 IShellFolder_fnCreateViewObject (IShellFolder2
* iface
, HWND hwndOwner
,
532 REFIID riid
, LPVOID
* ppvOut
)
534 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
536 LPSHELLVIEW pShellView
;
537 HRESULT hr
= E_INVALIDARG
;
539 TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This
, hwndOwner
, shdebugstr_guid (riid
),
545 if (IsEqualIID (riid
, &IID_IDropTarget
)) {
546 hr
= IShellFolder_QueryInterface (iface
, &IID_IDropTarget
, ppvOut
);
547 } else if (IsEqualIID (riid
, &IID_IContextMenu
)) {
548 FIXME ("IContextMenu not implemented\n");
550 } else if (IsEqualIID (riid
, &IID_IShellView
)) {
551 pShellView
= IShellView_Constructor ((IShellFolder
*) iface
);
553 hr
= IShellView_QueryInterface (pShellView
, riid
, ppvOut
);
554 IShellView_Release (pShellView
);
558 TRACE ("-- (%p)->(interface=%p)\n", This
, ppvOut
);
562 /**************************************************************************
563 * IShellFolder_fnGetAttributesOf
566 * UINT cidl, //[in ] num elements in pidl array
567 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
568 * ULONG* rgfInOut) //[out] result array
571 static HRESULT WINAPI
572 IShellFolder_fnGetAttributesOf (IShellFolder2
* iface
, UINT cidl
,
573 LPCITEMIDLIST
* apidl
, DWORD
* rgfInOut
)
575 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
579 TRACE ("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", This
, cidl
, apidl
,
582 if ((!cidl
) || (!apidl
) || (!rgfInOut
))
588 while (cidl
> 0 && *apidl
) {
590 SHELL32_GetItemAttributes (_IShellFolder_ (This
), *apidl
, rgfInOut
);
595 TRACE ("-- result=0x%08lx\n", *rgfInOut
);
600 /**************************************************************************
601 * IShellFolder_fnGetUIObjectOf
604 * HWND hwndOwner, //[in ] Parent window for any output
605 * UINT cidl, //[in ] array size
606 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
607 * REFIID riid, //[in ] Requested Interface
608 * UINT* prgfInOut, //[ ] reserved
609 * LPVOID* ppvObject) //[out] Resulting Interface
612 * This function gets asked to return "view objects" for one or more (multiple
614 * The viewobject typically is an COM object with one of the following
616 * IExtractIcon,IDataObject,IContextMenu
617 * In order to support icon positions in the default Listview your DataObject
618 * must implement the SetData method (in addition to GetData :) - the shell
619 * passes a barely documented "Icon positions" structure to SetData when the
620 * drag starts, and GetData's it if the drop is in another explorer window that
621 * needs the positions.
623 static HRESULT WINAPI
624 IShellFolder_fnGetUIObjectOf (IShellFolder2
* iface
,
626 UINT cidl
, LPCITEMIDLIST
* apidl
, REFIID riid
,
627 UINT
* prgfInOut
, LPVOID
* ppvOut
)
629 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
632 IUnknown
*pObj
= NULL
;
633 HRESULT hr
= E_INVALIDARG
;
635 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
636 This
, hwndOwner
, cidl
, apidl
, shdebugstr_guid (riid
), prgfInOut
, ppvOut
);
641 if (IsEqualIID (riid
, &IID_IContextMenu
) && (cidl
>= 1)) {
642 pObj
= (LPUNKNOWN
) ISvItemCm_Constructor ((IShellFolder
*) iface
,
643 This
->pidlRoot
, apidl
, cidl
);
645 } else if (IsEqualIID (riid
, &IID_IDataObject
) && (cidl
>= 1)) {
646 pObj
= (LPUNKNOWN
) IDataObject_Constructor (hwndOwner
,
647 This
->pidlRoot
, apidl
, cidl
);
649 } else if (IsEqualIID (riid
, &IID_IExtractIconA
) && (cidl
== 1)) {
650 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
651 pObj
= (LPUNKNOWN
) IExtractIconA_Constructor (pidl
);
654 } else if (IsEqualIID (riid
, &IID_IExtractIconW
) && (cidl
== 1)) {
655 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
656 pObj
= (LPUNKNOWN
) IExtractIconW_Constructor (pidl
);
659 } else if (IsEqualIID (riid
, &IID_IDropTarget
) && (cidl
>= 1)) {
660 hr
= IShellFolder_QueryInterface (iface
, &IID_IDropTarget
,
662 } else if ((IsEqualIID(riid
,&IID_IShellLinkW
) ||
663 IsEqualIID(riid
,&IID_IShellLinkA
)) && (cidl
== 1)) {
664 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
665 hr
= IShellLink_ConstructFromFile(NULL
, riid
, pidl
, (LPVOID
*)&pObj
);
671 if (SUCCEEDED(hr
) && !pObj
)
676 TRACE ("(%p)->hr=0x%08lx\n", This
, hr
);
680 static const WCHAR AdvancedW
[] = { 'S','O','F','T','W','A','R','E',
681 '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
682 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l',
683 'o','r','e','r','\\','A','d','v','a','n','c','e','d',0 };
684 static const WCHAR HideFileExtW
[] = { 'H','i','d','e','F','i','l','e','E','x',
686 static const WCHAR NeverShowExtW
[] = { 'N','e','v','e','r','S','h','o','w','E',
689 static BOOL
hide_extension(LPWSTR szPath
)
693 DWORD dwDataSize
= sizeof (DWORD
);
694 BOOL doHide
= FALSE
; /* The default value is FALSE (win98 at least) */
696 if (!RegCreateKeyExW(HKEY_CURRENT_USER
, AdvancedW
, 0, 0, 0, KEY_ALL_ACCESS
, 0, &hKey
, 0)) {
697 if (!RegQueryValueExW(hKey
, HideFileExtW
, 0, 0, (LPBYTE
) &dwData
, &dwDataSize
))
703 LPWSTR ext
= PathFindExtensionW(szPath
);
706 WCHAR classname
[MAX_PATH
];
707 LONG classlen
= sizeof(classname
);
709 if (!RegQueryValueW(HKEY_CLASSES_ROOT
, ext
, classname
, &classlen
))
710 if (!RegOpenKeyW(HKEY_CLASSES_ROOT
, classname
, &hKey
)) {
711 if (!RegQueryValueExW(hKey
, NeverShowExtW
, 0, NULL
, NULL
, NULL
))
720 void SHELL_FS_ProcessDisplayFilename(LPSTR szPath
, DWORD dwFlags
)
722 WCHAR pathW
[MAX_PATH
];
724 /*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */
725 if (!(dwFlags
& SHGDN_FORPARSING
) &&
726 ((dwFlags
& SHGDN_INFOLDER
) || (dwFlags
== SHGDN_NORMAL
))) {
727 MultiByteToWideChar(CP_ACP
, 0, szPath
, -1, pathW
, MAX_PATH
);
728 if (hide_extension(pathW
) && szPath
[0] != '.')
729 PathRemoveExtensionA (szPath
);
733 /**************************************************************************
734 * IShellFolder_fnGetDisplayNameOf
735 * Retrieves the display name for the specified file object or subfolder
738 * LPCITEMIDLIST pidl, //[in ] complex pidl to item
739 * DWORD dwFlags, //[in ] SHGNO formatting flags
740 * LPSTRRET lpName) //[out] Returned display name
743 * if the name is in the pidl the ret value should be a STRRET_OFFSET
746 static HRESULT WINAPI
747 IShellFolder_fnGetDisplayNameOf (IShellFolder2
* iface
, LPCITEMIDLIST pidl
,
748 DWORD dwFlags
, LPSTRRET strRet
)
750 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
752 CHAR szPath
[MAX_PATH
];
758 TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This
, pidl
, dwFlags
, strRet
);
761 if (!pidl
|| !strRet
)
764 bSimplePidl
= _ILIsPidlSimple (pidl
);
766 /* take names of special folders only if its only this folder */
767 if (_ILIsSpecialFolder (pidl
)) {
769 _ILSimpleGetText (pidl
, szPath
, MAX_PATH
); /* append my own path */
771 FIXME ("special pidl\n");
774 if (!(dwFlags
& SHGDN_INFOLDER
) && (dwFlags
& SHGDN_FORPARSING
) &&
776 /* get path to root */
777 lstrcpyA (szPath
, This
->sPathTarget
);
778 PathAddBackslashA (szPath
);
779 len
= lstrlenA (szPath
);
781 /* append my own path */
782 _ILSimpleGetText (pidl
, szPath
+ len
, MAX_PATH
- len
);
784 if (!_ILIsFolder(pidl
))
785 SHELL_FS_ProcessDisplayFilename(szPath
, dwFlags
);
788 /* go deeper if needed */
789 if ((dwFlags
& SHGDN_FORPARSING
) && !bSimplePidl
) {
790 PathAddBackslashA (szPath
);
791 len
= lstrlenA (szPath
);
793 if (!SUCCEEDED(SHELL32_GetDisplayNameOfChild (iface
, pidl
,
794 dwFlags
| SHGDN_INFOLDER
, szPath
+ len
, MAX_PATH
- len
)))
795 return E_OUTOFMEMORY
;
797 strRet
->uType
= STRRET_CSTR
;
798 lstrcpynA (strRet
->u
.cStr
, szPath
, MAX_PATH
);
800 TRACE ("-- (%p)->(%s)\n", This
, szPath
);
804 /**************************************************************************
805 * IShellFolder_fnSetNameOf
806 * Changes the name of a file object or subfolder, possibly changing its item
807 * identifier in the process.
810 * HWND hwndOwner, //[in ] Owner window for output
811 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
812 * LPCOLESTR lpszName, //[in ] the items new display name
813 * DWORD dwFlags, //[in ] SHGNO formatting flags
814 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
816 static HRESULT WINAPI
IShellFolder_fnSetNameOf (IShellFolder2
* iface
,
821 LPITEMIDLIST
* pPidlOut
)
823 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
824 WCHAR szSrc
[MAX_PATH
], szDest
[MAX_PATH
];
826 BOOL bIsFolder
= _ILIsFolder (ILFindLastID (pidl
));
828 TRACE ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This
, hwndOwner
, pidl
,
829 debugstr_w (lpName
), dwFlags
, pPidlOut
);
831 /* build source path */
832 MultiByteToWideChar(CP_ACP
, 0, This
->sPathTarget
, -1, szSrc
, MAX_PATH
);
833 ptr
= PathAddBackslashW (szSrc
);
835 _ILSimpleGetTextW (pidl
, ptr
, MAX_PATH
- (ptr
- szSrc
));
837 /* build destination path */
838 if (dwFlags
== SHGDN_NORMAL
|| dwFlags
& SHGDN_INFOLDER
) {
839 MultiByteToWideChar(CP_ACP
, 0, This
->sPathTarget
, -1, szDest
, MAX_PATH
);
840 ptr
= PathAddBackslashW (szDest
);
842 lstrcpynW(ptr
, lpName
, MAX_PATH
- (ptr
- szDest
));
844 lstrcpynW(szDest
, lpName
, MAX_PATH
);
846 if(!(dwFlags
& SHGDN_FORPARSING
) && hide_extension(szSrc
)) {
847 WCHAR
*ext
= PathFindExtensionW(szSrc
);
849 INT len
= strlenW(szDest
);
850 lstrcpynW(szDest
+ len
, ext
, MAX_PATH
- len
);
854 TRACE ("src=%s dest=%s\n", debugstr_w(szSrc
), debugstr_w(szDest
));
856 if (MoveFileW (szSrc
, szDest
)) {
860 hr
= _ILCreateFromPathW(szDest
, pPidlOut
);
862 SHChangeNotify (bIsFolder
? SHCNE_RENAMEFOLDER
: SHCNE_RENAMEITEM
,
863 SHCNF_PATHW
, szSrc
, szDest
);
871 static HRESULT WINAPI
IShellFolder_fnGetDefaultSearchGUID (IShellFolder2
*iface
,
874 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
875 FIXME ("(%p)\n", This
);
878 static HRESULT WINAPI
IShellFolder_fnEnumSearches (IShellFolder2
* iface
,
879 IEnumExtraSearch
** ppenum
)
881 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
882 FIXME ("(%p)\n", This
);
886 static HRESULT WINAPI
887 IShellFolder_fnGetDefaultColumn (IShellFolder2
* iface
, DWORD dwRes
,
888 ULONG
* pSort
, ULONG
* pDisplay
)
890 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
892 TRACE ("(%p)\n", This
);
902 static HRESULT WINAPI
903 IShellFolder_fnGetDefaultColumnState (IShellFolder2
* iface
, UINT iColumn
,
906 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
908 TRACE ("(%p)\n", This
);
910 if (!pcsFlags
|| iColumn
>= GENERICSHELLVIEWCOLUMNS
)
913 *pcsFlags
= GenericSFHeader
[iColumn
].pcsFlags
;
918 static HRESULT WINAPI
919 IShellFolder_fnGetDetailsEx (IShellFolder2
* iface
, LPCITEMIDLIST pidl
,
920 const SHCOLUMNID
* pscid
, VARIANT
* pv
)
922 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
923 FIXME ("(%p)\n", This
);
928 static HRESULT WINAPI
929 IShellFolder_fnGetDetailsOf (IShellFolder2
* iface
, LPCITEMIDLIST pidl
,
930 UINT iColumn
, SHELLDETAILS
* psd
)
932 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
935 TRACE ("(%p)->(%p %i %p)\n", This
, pidl
, iColumn
, psd
);
937 if (!psd
|| iColumn
>= GENERICSHELLVIEWCOLUMNS
)
941 /* the header titles */
942 psd
->fmt
= GenericSFHeader
[iColumn
].fmt
;
943 psd
->cxChar
= GenericSFHeader
[iColumn
].cxChar
;
944 psd
->str
.uType
= STRRET_CSTR
;
945 LoadStringA (shell32_hInstance
, GenericSFHeader
[iColumn
].colnameid
,
946 psd
->str
.u
.cStr
, MAX_PATH
);
949 /* the data from the pidl */
952 hr
= IShellFolder_GetDisplayNameOf (iface
, pidl
,
953 SHGDN_NORMAL
| SHGDN_INFOLDER
, &psd
->str
);
956 _ILGetFileSize (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
959 _ILGetFileType (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
962 _ILGetFileDate (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
964 case 4: /* attributes */
965 _ILGetFileAttributes (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
969 psd
->str
.uType
= STRRET_CSTR
;
975 static HRESULT WINAPI
976 IShellFolder_fnMapColumnToSCID (IShellFolder2
* iface
, UINT column
,
979 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl
, iface
)
980 FIXME ("(%p)\n", This
);
984 static IShellFolder2Vtbl sfvt
=
986 IShellFolder_fnQueryInterface
,
987 IShellFolder_fnAddRef
,
988 IShellFolder_fnRelease
,
989 IShellFolder_fnParseDisplayName
,
990 IShellFolder_fnEnumObjects
,
991 IShellFolder_fnBindToObject
,
992 IShellFolder_fnBindToStorage
,
993 IShellFolder_fnCompareIDs
,
994 IShellFolder_fnCreateViewObject
,
995 IShellFolder_fnGetAttributesOf
,
996 IShellFolder_fnGetUIObjectOf
,
997 IShellFolder_fnGetDisplayNameOf
,
998 IShellFolder_fnSetNameOf
,
1000 IShellFolder_fnGetDefaultSearchGUID
,
1001 IShellFolder_fnEnumSearches
,
1002 IShellFolder_fnGetDefaultColumn
,
1003 IShellFolder_fnGetDefaultColumnState
,
1004 IShellFolder_fnGetDetailsEx
,
1005 IShellFolder_fnGetDetailsOf
,
1006 IShellFolder_fnMapColumnToSCID
1009 /****************************************************************************
1010 * ISFHelper for IShellFolder implementation
1013 static HRESULT WINAPI
1014 ISFHelper_fnQueryInterface (ISFHelper
* iface
, REFIID riid
, LPVOID
* ppvObj
)
1016 _ICOM_THIS_From_ISFHelper (IGenericSFImpl
, iface
);
1018 TRACE ("(%p)->(count=%lu)\n", This
, This
->ref
);
1020 return IUnknown_QueryInterface (This
->pUnkOuter
, riid
, ppvObj
);
1023 static ULONG WINAPI
ISFHelper_fnAddRef (ISFHelper
* iface
)
1025 _ICOM_THIS_From_ISFHelper (IGenericSFImpl
, iface
);
1027 TRACE ("(%p)->(count=%lu)\n", This
, This
->ref
);
1029 return IUnknown_AddRef (This
->pUnkOuter
);
1032 static ULONG WINAPI
ISFHelper_fnRelease (ISFHelper
* iface
)
1034 _ICOM_THIS_From_ISFHelper (IGenericSFImpl
, iface
);
1036 TRACE ("(%p)\n", This
);
1038 return IUnknown_Release (This
->pUnkOuter
);
1041 /****************************************************************************
1042 * ISFHelper_fnAddFolder
1044 * creates a unique folder name
1047 static HRESULT WINAPI
1048 ISFHelper_fnGetUniqueName (ISFHelper
* iface
, LPSTR lpName
, UINT uLen
)
1050 _ICOM_THIS_From_ISFHelper (IGenericSFImpl
, iface
)
1053 char szText
[MAX_PATH
];
1054 char *szNewFolder
= "New Folder";
1056 TRACE ("(%p)(%s %u)\n", This
, lpName
, uLen
);
1058 if (uLen
< strlen (szNewFolder
) + 4)
1061 strcpy (lpName
, szNewFolder
);
1063 hr
= IShellFolder_fnEnumObjects (_IShellFolder2_ (This
), 0,
1064 SHCONTF_FOLDERS
| SHCONTF_NONFOLDERS
| SHCONTF_INCLUDEHIDDEN
, &penum
);
1071 IEnumIDList_Reset (penum
);
1072 while (S_OK
== IEnumIDList_Next (penum
, 1, &pidl
, &dwFetched
) &&
1074 _ILSimpleGetText (pidl
, szText
, MAX_PATH
);
1075 if (0 == strcasecmp (szText
, lpName
)) {
1076 sprintf (lpName
, "%s %d", szNewFolder
, i
++);
1085 IEnumIDList_Release (penum
);
1090 /****************************************************************************
1091 * ISFHelper_fnAddFolder
1093 * adds a new folder.
1096 static HRESULT WINAPI
1097 ISFHelper_fnAddFolder (ISFHelper
* iface
, HWND hwnd
, LPCSTR lpName
,
1098 LPITEMIDLIST
* ppidlOut
)
1100 _ICOM_THIS_From_ISFHelper (IGenericSFImpl
, iface
)
1101 char lpstrNewDir
[MAX_PATH
];
1103 HRESULT hres
= E_FAIL
;
1105 TRACE ("(%p)(%s %p)\n", This
, lpName
, ppidlOut
);
1107 strcpy (lpstrNewDir
, This
->sPathTarget
);
1108 PathAppendA(lpstrNewDir
, lpName
);
1110 bRes
= CreateDirectoryA (lpstrNewDir
, NULL
);
1112 SHChangeNotify (SHCNE_MKDIR
, SHCNF_PATHA
, lpstrNewDir
, NULL
);
1117 hres
= _ILCreateFromPathA(lpstrNewDir
, ppidlOut
);
1119 char lpstrText
[128 + MAX_PATH
];
1120 char lpstrTempText
[128];
1121 char lpstrCaption
[256];
1123 /* Cannot Create folder because of permissions */
1124 LoadStringA (shell32_hInstance
, IDS_CREATEFOLDER_DENIED
, lpstrTempText
,
1125 sizeof (lpstrTempText
));
1126 LoadStringA (shell32_hInstance
, IDS_CREATEFOLDER_CAPTION
, lpstrCaption
,
1127 sizeof (lpstrCaption
));
1128 sprintf (lpstrText
, lpstrTempText
, lpstrNewDir
);
1129 MessageBoxA (hwnd
, lpstrText
, lpstrCaption
, MB_OK
| MB_ICONEXCLAMATION
);
1135 /****************************************************************************
1136 * ISFHelper_fnDeleteItems
1138 * deletes items in folder
1140 static HRESULT WINAPI
1141 ISFHelper_fnDeleteItems (ISFHelper
* iface
, UINT cidl
, LPCITEMIDLIST
* apidl
)
1143 _ICOM_THIS_From_ISFHelper (IGenericSFImpl
, iface
)
1145 char szPath
[MAX_PATH
];
1146 BOOL bConfirm
= TRUE
;
1148 TRACE ("(%p)(%u %p)\n", This
, cidl
, apidl
);
1150 /* deleting multiple items so give a slightly different warning */
1154 snprintf (tmp
, sizeof (tmp
), "%d", cidl
);
1155 if (!SHELL_ConfirmDialog(ASK_DELETE_MULTIPLE_ITEM
, tmp
))
1160 for (i
= 0; i
< cidl
; i
++) {
1161 strcpy (szPath
, This
->sPathTarget
);
1162 PathAddBackslashA (szPath
);
1163 _ILSimpleGetText (apidl
[i
], szPath
+ strlen (szPath
), MAX_PATH
);
1165 if (_ILIsFolder (apidl
[i
])) {
1168 TRACE ("delete %s\n", szPath
);
1169 if (!SHELL_DeleteDirectoryA (szPath
, bConfirm
)) {
1170 TRACE ("delete %s failed, bConfirm=%d\n", szPath
, bConfirm
);
1173 pidl
= ILCombine (This
->pidlRoot
, apidl
[i
]);
1174 SHChangeNotify (SHCNE_RMDIR
, SHCNF_IDLIST
, pidl
, NULL
);
1176 } else if (_ILIsValue (apidl
[i
])) {
1179 TRACE ("delete %s\n", szPath
);
1180 if (!SHELL_DeleteFileA (szPath
, bConfirm
)) {
1181 TRACE ("delete %s failed, bConfirm=%d\n", szPath
, bConfirm
);
1184 pidl
= ILCombine (This
->pidlRoot
, apidl
[i
]);
1185 SHChangeNotify (SHCNE_DELETE
, SHCNF_IDLIST
, pidl
, NULL
);
1193 /****************************************************************************
1194 * ISFHelper_fnCopyItems
1196 * copies items to this folder
1198 static HRESULT WINAPI
1199 ISFHelper_fnCopyItems (ISFHelper
* iface
, IShellFolder
* pSFFrom
, UINT cidl
,
1200 LPCITEMIDLIST
* apidl
)
1203 IPersistFolder2
*ppf2
= NULL
;
1204 char szSrcPath
[MAX_PATH
],
1205 szDstPath
[MAX_PATH
];
1207 _ICOM_THIS_From_ISFHelper (IGenericSFImpl
, iface
);
1209 TRACE ("(%p)->(%p,%u,%p)\n", This
, pSFFrom
, cidl
, apidl
);
1211 IShellFolder_QueryInterface (pSFFrom
, &IID_IPersistFolder2
,
1216 if (SUCCEEDED (IPersistFolder2_GetCurFolder (ppf2
, &pidl
))) {
1217 for (i
= 0; i
< cidl
; i
++) {
1218 SHGetPathFromIDListA (pidl
, szSrcPath
);
1219 PathAddBackslashA (szSrcPath
);
1220 _ILSimpleGetText (apidl
[i
], szSrcPath
+ strlen (szSrcPath
),
1223 strcpy (szDstPath
, This
->sPathTarget
);
1224 PathAddBackslashA (szDstPath
);
1225 _ILSimpleGetText (apidl
[i
], szDstPath
+ strlen (szDstPath
),
1227 MESSAGE ("would copy %s to %s\n", szSrcPath
, szDstPath
);
1231 IPersistFolder2_Release (ppf2
);
1236 static ISFHelperVtbl shvt
=
1238 ISFHelper_fnQueryInterface
,
1240 ISFHelper_fnRelease
,
1241 ISFHelper_fnGetUniqueName
,
1242 ISFHelper_fnAddFolder
,
1243 ISFHelper_fnDeleteItems
,
1244 ISFHelper_fnCopyItems
1247 /************************************************************************
1248 * IFSFldr_PersistFolder3_QueryInterface
1251 static HRESULT WINAPI
1252 IFSFldr_PersistFolder3_QueryInterface (IPersistFolder3
* iface
, REFIID iid
,
1255 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl
, iface
);
1257 TRACE ("(%p)\n", This
);
1259 return IUnknown_QueryInterface (This
->pUnkOuter
, iid
, ppvObj
);
1262 /************************************************************************
1263 * IFSFldr_PersistFolder3_AddRef
1267 IFSFldr_PersistFolder3_AddRef (IPersistFolder3
* iface
)
1269 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl
, iface
);
1271 TRACE ("(%p)->(count=%lu)\n", This
, This
->ref
);
1273 return IUnknown_AddRef (This
->pUnkOuter
);
1276 /************************************************************************
1277 * IFSFldr_PersistFolder3_Release
1281 IFSFldr_PersistFolder3_Release (IPersistFolder3
* iface
)
1283 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl
, iface
);
1285 TRACE ("(%p)->(count=%lu)\n", This
, This
->ref
);
1287 return IUnknown_Release (This
->pUnkOuter
);
1290 /************************************************************************
1291 * IFSFldr_PersistFolder3_GetClassID
1293 static HRESULT WINAPI
1294 IFSFldr_PersistFolder3_GetClassID (IPersistFolder3
* iface
, CLSID
* lpClassId
)
1296 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl
, iface
);
1298 TRACE ("(%p)\n", This
);
1302 *lpClassId
= *This
->pclsid
;
1307 /************************************************************************
1308 * IFSFldr_PersistFolder3_Initialize
1311 * sPathTarget is not set. Don't know how to handle in a non rooted environment.
1313 static HRESULT WINAPI
1314 IFSFldr_PersistFolder3_Initialize (IPersistFolder3
* iface
, LPCITEMIDLIST pidl
)
1316 char sTemp
[MAX_PATH
];
1318 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl
, iface
);
1320 TRACE ("(%p)->(%p)\n", This
, pidl
);
1323 SHFree (This
->pidlRoot
); /* free the old pidl */
1324 This
->pidlRoot
= ILClone (pidl
); /* set my pidl */
1326 if (This
->sPathTarget
)
1327 SHFree (This
->sPathTarget
);
1330 if (SHGetPathFromIDListA (pidl
, sTemp
)) {
1331 This
->sPathTarget
= SHAlloc (strlen (sTemp
) + 1);
1332 strcpy (This
->sPathTarget
, sTemp
);
1335 TRACE ("--(%p)->(%s)\n", This
, This
->sPathTarget
);
1339 /**************************************************************************
1340 * IFSFldr_PersistFolder3_GetCurFolder
1342 static HRESULT WINAPI
1343 IFSFldr_PersistFolder3_fnGetCurFolder (IPersistFolder3
* iface
,
1344 LPITEMIDLIST
* pidl
)
1346 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl
, iface
);
1348 TRACE ("(%p)->(%p)\n", This
, pidl
);
1350 if (!pidl
) return E_POINTER
;
1351 *pidl
= ILClone (This
->pidlRoot
);
1355 /**************************************************************************
1356 * IFSFldr_PersistFolder3_InitializeEx
1358 * FIXME: error handling
1360 static HRESULT WINAPI
1361 IFSFldr_PersistFolder3_InitializeEx (IPersistFolder3
* iface
,
1362 IBindCtx
* pbc
, LPCITEMIDLIST pidlRoot
,
1363 const PERSIST_FOLDER_TARGET_INFO
* ppfti
)
1365 char sTemp
[MAX_PATH
];
1367 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl
, iface
);
1369 TRACE ("(%p)->(%p,%p,%p)\n", This
, pbc
, pidlRoot
, ppfti
);
1371 TRACE ("--%p %s %s 0x%08lx 0x%08x\n",
1372 ppfti
->pidlTargetFolder
, debugstr_w (ppfti
->szTargetParsingName
),
1373 debugstr_w (ppfti
->szNetworkProvider
), ppfti
->dwAttributes
,
1377 if (ppfti
&& ppfti
->pidlTargetFolder
)
1378 pdump (ppfti
->pidlTargetFolder
);
1381 __SHFreeAndNil (&This
->pidlRoot
); /* free the old */
1382 if (This
->sPathTarget
)
1383 __SHFreeAndNil (&This
->sPathTarget
);
1386 * Root path and pidl
1388 This
->pidlRoot
= ILClone (pidlRoot
);
1391 * the target folder is spezified in csidl OR pidlTargetFolder OR
1392 * szTargetParsingName
1395 if (ppfti
->csidl
!= -1) {
1396 if (SHGetSpecialFolderPathA (0, sTemp
, ppfti
->csidl
,
1397 ppfti
->csidl
& CSIDL_FLAG_CREATE
)) {
1398 __SHCloneStrA (&This
->sPathTarget
, sTemp
);
1400 } else if (ppfti
->szTargetParsingName
[0]) {
1401 __SHCloneStrWtoA (&This
->sPathTarget
, ppfti
->szTargetParsingName
);
1402 } else if (ppfti
->pidlTargetFolder
) {
1403 if (SHGetPathFromIDListA (ppfti
->pidlTargetFolder
, sTemp
)) {
1404 __SHCloneStrA (&This
->sPathTarget
, sTemp
);
1409 TRACE ("--(%p)->(target=%s)\n", This
, debugstr_a (This
->sPathTarget
));
1410 pdump (This
->pidlRoot
);
1411 return (This
->sPathTarget
) ? S_OK
: E_FAIL
;
1414 static HRESULT WINAPI
1415 IFSFldr_PersistFolder3_GetFolderTargetInfo (IPersistFolder3
* iface
,
1416 PERSIST_FOLDER_TARGET_INFO
* ppfti
)
1418 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl
, iface
);
1419 FIXME ("(%p)->(%p)\n", This
, ppfti
);
1420 ZeroMemory (ppfti
, sizeof (ppfti
));
1424 static IPersistFolder3Vtbl vt_FSFldr_PersistFolder3
=
1426 IFSFldr_PersistFolder3_QueryInterface
,
1427 IFSFldr_PersistFolder3_AddRef
,
1428 IFSFldr_PersistFolder3_Release
,
1429 IFSFldr_PersistFolder3_GetClassID
,
1430 IFSFldr_PersistFolder3_Initialize
,
1431 IFSFldr_PersistFolder3_fnGetCurFolder
,
1432 IFSFldr_PersistFolder3_InitializeEx
,
1433 IFSFldr_PersistFolder3_GetFolderTargetInfo
1436 /****************************************************************************
1437 * ISFDropTarget implementation
1440 ISFDropTarget_QueryDrop (IDropTarget
* iface
, DWORD dwKeyState
,
1443 DWORD dwEffect
= *pdwEffect
;
1445 _ICOM_THIS_From_IDropTarget (IGenericSFImpl
, iface
);
1447 *pdwEffect
= DROPEFFECT_NONE
;
1449 if (This
->fAcceptFmt
) { /* Does our interpretation of the keystate ... */
1450 *pdwEffect
= KeyStateToDropEffect (dwKeyState
);
1452 /* ... matches the desired effect ? */
1453 if (dwEffect
& *pdwEffect
) {
1460 static HRESULT WINAPI
1461 ISFDropTarget_QueryInterface (IDropTarget
* iface
, REFIID riid
, LPVOID
* ppvObj
)
1463 _ICOM_THIS_From_IDropTarget (IGenericSFImpl
, iface
);
1465 TRACE ("(%p)\n", This
);
1467 return IUnknown_QueryInterface (This
->pUnkOuter
, riid
, ppvObj
);
1470 static ULONG WINAPI
ISFDropTarget_AddRef (IDropTarget
* iface
)
1472 _ICOM_THIS_From_IDropTarget (IGenericSFImpl
, iface
);
1474 TRACE ("(%p)\n", This
);
1476 return IUnknown_AddRef (This
->pUnkOuter
);
1479 static ULONG WINAPI
ISFDropTarget_Release (IDropTarget
* iface
)
1481 _ICOM_THIS_From_IDropTarget (IGenericSFImpl
, iface
);
1483 TRACE ("(%p)\n", This
);
1485 return IUnknown_Release (This
->pUnkOuter
);
1488 static HRESULT WINAPI
1489 ISFDropTarget_DragEnter (IDropTarget
* iface
, IDataObject
* pDataObject
,
1490 DWORD dwKeyState
, POINTL pt
, DWORD
* pdwEffect
)
1494 _ICOM_THIS_From_IDropTarget (IGenericSFImpl
, iface
);
1496 TRACE ("(%p)->(DataObject=%p)\n", This
, pDataObject
);
1498 InitFormatEtc (fmt
, This
->cfShellIDList
, TYMED_HGLOBAL
);
1500 This
->fAcceptFmt
= (S_OK
== IDataObject_QueryGetData (pDataObject
, &fmt
)) ?
1503 ISFDropTarget_QueryDrop (iface
, dwKeyState
, pdwEffect
);
1508 static HRESULT WINAPI
1509 ISFDropTarget_DragOver (IDropTarget
* iface
, DWORD dwKeyState
, POINTL pt
,
1512 _ICOM_THIS_From_IDropTarget (IGenericSFImpl
, iface
);
1514 TRACE ("(%p)\n", This
);
1517 return E_INVALIDARG
;
1519 ISFDropTarget_QueryDrop (iface
, dwKeyState
, pdwEffect
);
1524 static HRESULT WINAPI
ISFDropTarget_DragLeave (IDropTarget
* iface
)
1526 _ICOM_THIS_From_IDropTarget (IGenericSFImpl
, iface
);
1528 TRACE ("(%p)\n", This
);
1530 This
->fAcceptFmt
= FALSE
;
1535 static HRESULT WINAPI
1536 ISFDropTarget_Drop (IDropTarget
* iface
, IDataObject
* pDataObject
,
1537 DWORD dwKeyState
, POINTL pt
, DWORD
* pdwEffect
)
1539 _ICOM_THIS_From_IDropTarget (IGenericSFImpl
, iface
);
1541 FIXME ("(%p) object dropped\n", This
);
1546 static struct IDropTargetVtbl dtvt
= {
1547 ISFDropTarget_QueryInterface
,
1548 ISFDropTarget_AddRef
,
1549 ISFDropTarget_Release
,
1550 ISFDropTarget_DragEnter
,
1551 ISFDropTarget_DragOver
,
1552 ISFDropTarget_DragLeave
,