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=%p (0x%08lx))\n", This, cidl, apidl,
580 rgfInOut, rgfInOut ? *rgfInOut : 0);
590 while (cidl > 0 && *apidl) {
592 SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut);
596 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
597 *rgfInOut &= ~SFGAO_VALIDATE;
599 TRACE ("-- result=0x%08lx\n", *rgfInOut);
604 /**************************************************************************
605 * IShellFolder_fnGetUIObjectOf
608 * HWND hwndOwner, //[in ] Parent window for any output
609 * UINT cidl, //[in ] array size
610 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
611 * REFIID riid, //[in ] Requested Interface
612 * UINT* prgfInOut, //[ ] reserved
613 * LPVOID* ppvObject) //[out] Resulting Interface
616 * This function gets asked to return "view objects" for one or more (multiple
618 * The viewobject typically is an COM object with one of the following
620 * IExtractIcon,IDataObject,IContextMenu
621 * In order to support icon positions in the default Listview your DataObject
622 * must implement the SetData method (in addition to GetData :) - the shell
623 * passes a barely documented "Icon positions" structure to SetData when the
624 * drag starts, and GetData's it if the drop is in another explorer window that
625 * needs the positions.
627 static HRESULT WINAPI
628 IShellFolder_fnGetUIObjectOf (IShellFolder2 * iface,
630 UINT cidl, LPCITEMIDLIST * apidl, REFIID riid,
631 UINT * prgfInOut, LPVOID * ppvOut)
633 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
636 IUnknown *pObj = NULL;
637 HRESULT hr = E_INVALIDARG;
639 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
640 This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
645 if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) {
646 pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface,
647 This->pidlRoot, apidl, cidl);
649 } else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) {
650 pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner,
651 This->pidlRoot, apidl, cidl);
653 } else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) {
654 pidl = ILCombine (This->pidlRoot, apidl[0]);
655 pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
658 } else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) {
659 pidl = ILCombine (This->pidlRoot, apidl[0]);
660 pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
663 } else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) {
664 hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget,
666 } else if ((IsEqualIID(riid,&IID_IShellLinkW) ||
667 IsEqualIID(riid,&IID_IShellLinkA)) && (cidl == 1)) {
668 pidl = ILCombine (This->pidlRoot, apidl[0]);
669 hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj);
675 if (SUCCEEDED(hr) && !pObj)
680 TRACE ("(%p)->hr=0x%08lx\n", This, hr);
684 static const WCHAR AdvancedW[] = { 'S','O','F','T','W','A','R','E',
685 '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
686 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l',
687 'o','r','e','r','\\','A','d','v','a','n','c','e','d',0 };
688 static const WCHAR HideFileExtW[] = { 'H','i','d','e','F','i','l','e','E','x',
690 static const WCHAR NeverShowExtW[] = { 'N','e','v','e','r','S','h','o','w','E',
693 static BOOL hide_extension(LPWSTR szPath)
697 DWORD dwDataSize = sizeof (DWORD);
698 BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */
700 if (!RegCreateKeyExW(HKEY_CURRENT_USER, AdvancedW, 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0)) {
701 if (!RegQueryValueExW(hKey, HideFileExtW, 0, 0, (LPBYTE) &dwData, &dwDataSize))
707 LPWSTR ext = PathFindExtensionW(szPath);
710 WCHAR classname[MAX_PATH];
711 LONG classlen = sizeof(classname);
713 if (!RegQueryValueW(HKEY_CLASSES_ROOT, ext, classname, &classlen))
714 if (!RegOpenKeyW(HKEY_CLASSES_ROOT, classname, &hKey)) {
715 if (!RegQueryValueExW(hKey, NeverShowExtW, 0, NULL, NULL, NULL))
724 void SHELL_FS_ProcessDisplayFilename(LPSTR szPath, DWORD dwFlags)
726 WCHAR pathW[MAX_PATH];
728 /*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */
729 if (!(dwFlags & SHGDN_FORPARSING) &&
730 ((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) {
731 MultiByteToWideChar(CP_ACP, 0, szPath, -1, pathW, MAX_PATH);
732 if (hide_extension(pathW) && szPath[0] != '.')
733 PathRemoveExtensionA (szPath);
737 /**************************************************************************
738 * IShellFolder_fnGetDisplayNameOf
739 * Retrieves the display name for the specified file object or subfolder
742 * LPCITEMIDLIST pidl, //[in ] complex pidl to item
743 * DWORD dwFlags, //[in ] SHGNO formatting flags
744 * LPSTRRET lpName) //[out] Returned display name
747 * if the name is in the pidl the ret value should be a STRRET_OFFSET
750 static HRESULT WINAPI
751 IShellFolder_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl,
752 DWORD dwFlags, LPSTRRET strRet)
754 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
759 TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet);
762 if (!pidl || !strRet)
765 strRet->uType = STRRET_CSTR;
766 if (_ILIsDesktop(pidl)) { /* empty pidl */
767 if ((GET_SHGDN_FOR(dwFlags) == SHGDN_FORPARSING) &&
768 (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER))
770 if (This->sPathTarget)
771 lstrcpynA(strRet->u.cStr, This->sPathTarget, MAX_PATH);
773 /* pidl has to contain exactly one non null SHITEMID */
776 } else if (_ILIsPidlSimple(pidl)) {
777 if ((GET_SHGDN_FOR(dwFlags) == SHGDN_FORPARSING) &&
778 (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER) &&
781 lstrcpynA(strRet->u.cStr, This->sPathTarget, MAX_PATH);
782 PathAddBackslashA(strRet->u.cStr);
783 len = lstrlenA(strRet->u.cStr);
785 _ILSimpleGetText(pidl, strRet->u.cStr + len, MAX_PATH - len);
786 if (!_ILIsFolder(pidl)) SHELL_FS_ProcessDisplayFilename(strRet->u.cStr, dwFlags);
788 hr = SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, strRet->u.cStr, MAX_PATH);
791 TRACE ("-- (%p)->(%s)\n", This, strRet->u.cStr);
795 /**************************************************************************
796 * IShellFolder_fnSetNameOf
797 * Changes the name of a file object or subfolder, possibly changing its item
798 * identifier in the process.
801 * HWND hwndOwner, //[in ] Owner window for output
802 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
803 * LPCOLESTR lpszName, //[in ] the items new display name
804 * DWORD dwFlags, //[in ] SHGNO formatting flags
805 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
807 static HRESULT WINAPI IShellFolder_fnSetNameOf (IShellFolder2 * iface,
812 LPITEMIDLIST * pPidlOut)
814 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
815 WCHAR szSrc[MAX_PATH], szDest[MAX_PATH];
817 BOOL bIsFolder = _ILIsFolder (ILFindLastID (pidl));
819 TRACE ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl,
820 debugstr_w (lpName), dwFlags, pPidlOut);
822 /* build source path */
823 MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szSrc, MAX_PATH);
824 ptr = PathAddBackslashW (szSrc);
826 _ILSimpleGetTextW (pidl, ptr, MAX_PATH - (ptr - szSrc));
828 /* build destination path */
829 if (dwFlags == SHGDN_NORMAL || dwFlags & SHGDN_INFOLDER) {
830 MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szDest, MAX_PATH);
831 ptr = PathAddBackslashW (szDest);
833 lstrcpynW(ptr, lpName, MAX_PATH - (ptr - szDest));
835 lstrcpynW(szDest, lpName, MAX_PATH);
837 if(!(dwFlags & SHGDN_FORPARSING) && hide_extension(szSrc)) {
838 WCHAR *ext = PathFindExtensionW(szSrc);
840 INT len = strlenW(szDest);
841 lstrcpynW(szDest + len, ext, MAX_PATH - len);
845 TRACE ("src=%s dest=%s\n", debugstr_w(szSrc), debugstr_w(szDest));
847 if (MoveFileW (szSrc, szDest)) {
851 hr = _ILCreateFromPathW(szDest, pPidlOut);
853 SHChangeNotify (bIsFolder ? SHCNE_RENAMEFOLDER : SHCNE_RENAMEITEM,
854 SHCNF_PATHW, szSrc, szDest);
862 static HRESULT WINAPI IShellFolder_fnGetDefaultSearchGUID (IShellFolder2 *iface,
865 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
866 FIXME ("(%p)\n", This);
869 static HRESULT WINAPI IShellFolder_fnEnumSearches (IShellFolder2 * iface,
870 IEnumExtraSearch ** ppenum)
872 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
873 FIXME ("(%p)\n", This);
877 static HRESULT WINAPI
878 IShellFolder_fnGetDefaultColumn (IShellFolder2 * iface, DWORD dwRes,
879 ULONG * pSort, ULONG * pDisplay)
881 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
883 TRACE ("(%p)\n", This);
893 static HRESULT WINAPI
894 IShellFolder_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn,
897 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
899 TRACE ("(%p)\n", This);
901 if (!pcsFlags || iColumn >= GENERICSHELLVIEWCOLUMNS)
904 *pcsFlags = GenericSFHeader[iColumn].pcsFlags;
909 static HRESULT WINAPI
910 IShellFolder_fnGetDetailsEx (IShellFolder2 * iface, LPCITEMIDLIST pidl,
911 const SHCOLUMNID * pscid, VARIANT * pv)
913 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
914 FIXME ("(%p)\n", This);
919 static HRESULT WINAPI
920 IShellFolder_fnGetDetailsOf (IShellFolder2 * iface, LPCITEMIDLIST pidl,
921 UINT iColumn, SHELLDETAILS * psd)
923 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
926 TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
928 if (!psd || iColumn >= GENERICSHELLVIEWCOLUMNS)
932 /* the header titles */
933 psd->fmt = GenericSFHeader[iColumn].fmt;
934 psd->cxChar = GenericSFHeader[iColumn].cxChar;
935 psd->str.uType = STRRET_CSTR;
936 LoadStringA (shell32_hInstance, GenericSFHeader[iColumn].colnameid,
937 psd->str.u.cStr, MAX_PATH);
940 /* the data from the pidl */
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);
960 psd->str.uType = STRRET_CSTR;
966 static HRESULT WINAPI
967 IShellFolder_fnMapColumnToSCID (IShellFolder2 * iface, UINT column,
970 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
971 FIXME ("(%p)\n", This);
975 static IShellFolder2Vtbl sfvt =
977 IShellFolder_fnQueryInterface,
978 IShellFolder_fnAddRef,
979 IShellFolder_fnRelease,
980 IShellFolder_fnParseDisplayName,
981 IShellFolder_fnEnumObjects,
982 IShellFolder_fnBindToObject,
983 IShellFolder_fnBindToStorage,
984 IShellFolder_fnCompareIDs,
985 IShellFolder_fnCreateViewObject,
986 IShellFolder_fnGetAttributesOf,
987 IShellFolder_fnGetUIObjectOf,
988 IShellFolder_fnGetDisplayNameOf,
989 IShellFolder_fnSetNameOf,
991 IShellFolder_fnGetDefaultSearchGUID,
992 IShellFolder_fnEnumSearches,
993 IShellFolder_fnGetDefaultColumn,
994 IShellFolder_fnGetDefaultColumnState,
995 IShellFolder_fnGetDetailsEx,
996 IShellFolder_fnGetDetailsOf,
997 IShellFolder_fnMapColumnToSCID
1000 /****************************************************************************
1001 * ISFHelper for IShellFolder implementation
1004 static HRESULT WINAPI
1005 ISFHelper_fnQueryInterface (ISFHelper * iface, REFIID riid, LPVOID * ppvObj)
1007 _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface);
1009 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
1011 return IUnknown_QueryInterface (This->pUnkOuter, riid, ppvObj);
1014 static ULONG WINAPI ISFHelper_fnAddRef (ISFHelper * iface)
1016 _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface);
1018 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
1020 return IUnknown_AddRef (This->pUnkOuter);
1023 static ULONG WINAPI ISFHelper_fnRelease (ISFHelper * iface)
1025 _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface);
1027 TRACE ("(%p)\n", This);
1029 return IUnknown_Release (This->pUnkOuter);
1032 /****************************************************************************
1033 * ISFHelper_fnAddFolder
1035 * creates a unique folder name
1038 static HRESULT WINAPI
1039 ISFHelper_fnGetUniqueName (ISFHelper * iface, LPSTR lpName, UINT uLen)
1041 _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface)
1044 char szText[MAX_PATH];
1045 char *szNewFolder = "New Folder";
1047 TRACE ("(%p)(%s %u)\n", This, lpName, uLen);
1049 if (uLen < strlen (szNewFolder) + 4)
1052 strcpy (lpName, szNewFolder);
1054 hr = IShellFolder_fnEnumObjects (_IShellFolder2_ (This), 0,
1055 SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &penum);
1062 IEnumIDList_Reset (penum);
1063 while (S_OK == IEnumIDList_Next (penum, 1, &pidl, &dwFetched) &&
1065 _ILSimpleGetText (pidl, szText, MAX_PATH);
1066 if (0 == strcasecmp (szText, lpName)) {
1067 sprintf (lpName, "%s %d", szNewFolder, i++);
1076 IEnumIDList_Release (penum);
1081 /****************************************************************************
1082 * ISFHelper_fnAddFolder
1084 * adds a new folder.
1087 static HRESULT WINAPI
1088 ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCSTR lpName,
1089 LPITEMIDLIST * ppidlOut)
1091 _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface)
1092 char lpstrNewDir[MAX_PATH];
1094 HRESULT hres = E_FAIL;
1096 TRACE ("(%p)(%s %p)\n", This, lpName, ppidlOut);
1098 strcpy (lpstrNewDir, This->sPathTarget);
1099 PathAppendA(lpstrNewDir, lpName);
1101 bRes = CreateDirectoryA (lpstrNewDir, NULL);
1103 SHChangeNotify (SHCNE_MKDIR, SHCNF_PATHA, lpstrNewDir, NULL);
1108 hres = _ILCreateFromPathA(lpstrNewDir, ppidlOut);
1110 char lpstrText[128 + MAX_PATH];
1111 char lpstrTempText[128];
1112 char lpstrCaption[256];
1114 /* Cannot Create folder because of permissions */
1115 LoadStringA (shell32_hInstance, IDS_CREATEFOLDER_DENIED, lpstrTempText,
1116 sizeof (lpstrTempText));
1117 LoadStringA (shell32_hInstance, IDS_CREATEFOLDER_CAPTION, lpstrCaption,
1118 sizeof (lpstrCaption));
1119 sprintf (lpstrText, lpstrTempText, lpstrNewDir);
1120 MessageBoxA (hwnd, lpstrText, lpstrCaption, MB_OK | MB_ICONEXCLAMATION);
1126 /****************************************************************************
1127 * ISFHelper_fnDeleteItems
1129 * deletes items in folder
1131 static HRESULT WINAPI
1132 ISFHelper_fnDeleteItems (ISFHelper * iface, UINT cidl, LPCITEMIDLIST * apidl)
1134 _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface)
1136 char szPath[MAX_PATH];
1137 BOOL bConfirm = TRUE;
1139 TRACE ("(%p)(%u %p)\n", This, cidl, apidl);
1141 /* deleting multiple items so give a slightly different warning */
1145 snprintf (tmp, sizeof (tmp), "%d", cidl);
1146 if (!SHELL_ConfirmDialog(ASK_DELETE_MULTIPLE_ITEM, tmp))
1151 for (i = 0; i < cidl; i++) {
1152 strcpy (szPath, This->sPathTarget);
1153 PathAddBackslashA (szPath);
1154 _ILSimpleGetText (apidl[i], szPath + strlen (szPath), MAX_PATH);
1156 if (_ILIsFolder (apidl[i])) {
1159 TRACE ("delete %s\n", szPath);
1160 if (!SHELL_DeleteDirectoryA (szPath, bConfirm)) {
1161 TRACE ("delete %s failed, bConfirm=%d\n", szPath, bConfirm);
1164 pidl = ILCombine (This->pidlRoot, apidl[i]);
1165 SHChangeNotify (SHCNE_RMDIR, SHCNF_IDLIST, pidl, NULL);
1167 } else if (_ILIsValue (apidl[i])) {
1170 TRACE ("delete %s\n", szPath);
1171 if (!SHELL_DeleteFileA (szPath, bConfirm)) {
1172 TRACE ("delete %s failed, bConfirm=%d\n", szPath, bConfirm);
1175 pidl = ILCombine (This->pidlRoot, apidl[i]);
1176 SHChangeNotify (SHCNE_DELETE, SHCNF_IDLIST, pidl, NULL);
1184 /****************************************************************************
1185 * ISFHelper_fnCopyItems
1187 * copies items to this folder
1189 static HRESULT WINAPI
1190 ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl,
1191 LPCITEMIDLIST * apidl)
1194 IPersistFolder2 *ppf2 = NULL;
1195 char szSrcPath[MAX_PATH],
1196 szDstPath[MAX_PATH];
1198 _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface);
1200 TRACE ("(%p)->(%p,%u,%p)\n", This, pSFFrom, cidl, apidl);
1202 IShellFolder_QueryInterface (pSFFrom, &IID_IPersistFolder2,
1207 if (SUCCEEDED (IPersistFolder2_GetCurFolder (ppf2, &pidl))) {
1208 for (i = 0; i < cidl; i++) {
1209 SHGetPathFromIDListA (pidl, szSrcPath);
1210 PathAddBackslashA (szSrcPath);
1211 _ILSimpleGetText (apidl[i], szSrcPath + strlen (szSrcPath),
1214 strcpy (szDstPath, This->sPathTarget);
1215 PathAddBackslashA (szDstPath);
1216 _ILSimpleGetText (apidl[i], szDstPath + strlen (szDstPath),
1218 MESSAGE ("would copy %s to %s\n", szSrcPath, szDstPath);
1222 IPersistFolder2_Release (ppf2);
1227 static ISFHelperVtbl shvt =
1229 ISFHelper_fnQueryInterface,
1231 ISFHelper_fnRelease,
1232 ISFHelper_fnGetUniqueName,
1233 ISFHelper_fnAddFolder,
1234 ISFHelper_fnDeleteItems,
1235 ISFHelper_fnCopyItems
1238 /************************************************************************
1239 * IFSFldr_PersistFolder3_QueryInterface
1242 static HRESULT WINAPI
1243 IFSFldr_PersistFolder3_QueryInterface (IPersistFolder3 * iface, REFIID iid,
1246 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1248 TRACE ("(%p)\n", This);
1250 return IUnknown_QueryInterface (This->pUnkOuter, iid, ppvObj);
1253 /************************************************************************
1254 * IFSFldr_PersistFolder3_AddRef
1258 IFSFldr_PersistFolder3_AddRef (IPersistFolder3 * iface)
1260 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1262 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
1264 return IUnknown_AddRef (This->pUnkOuter);
1267 /************************************************************************
1268 * IFSFldr_PersistFolder3_Release
1272 IFSFldr_PersistFolder3_Release (IPersistFolder3 * iface)
1274 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1276 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
1278 return IUnknown_Release (This->pUnkOuter);
1281 /************************************************************************
1282 * IFSFldr_PersistFolder3_GetClassID
1284 static HRESULT WINAPI
1285 IFSFldr_PersistFolder3_GetClassID (IPersistFolder3 * iface, CLSID * lpClassId)
1287 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1289 TRACE ("(%p)\n", This);
1293 *lpClassId = *This->pclsid;
1298 /************************************************************************
1299 * IFSFldr_PersistFolder3_Initialize
1302 * sPathTarget is not set. Don't know how to handle in a non rooted environment.
1304 static HRESULT WINAPI
1305 IFSFldr_PersistFolder3_Initialize (IPersistFolder3 * iface, LPCITEMIDLIST pidl)
1307 char sTemp[MAX_PATH];
1309 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1311 TRACE ("(%p)->(%p)\n", This, pidl);
1314 SHFree (This->pidlRoot); /* free the old pidl */
1315 This->pidlRoot = ILClone (pidl); /* set my pidl */
1317 if (This->sPathTarget)
1318 SHFree (This->sPathTarget);
1321 if (SHGetPathFromIDListA (pidl, sTemp)) {
1322 This->sPathTarget = SHAlloc (strlen (sTemp) + 1);
1323 strcpy (This->sPathTarget, sTemp);
1326 TRACE ("--(%p)->(%s)\n", This, This->sPathTarget);
1330 /**************************************************************************
1331 * IFSFldr_PersistFolder3_GetCurFolder
1333 static HRESULT WINAPI
1334 IFSFldr_PersistFolder3_fnGetCurFolder (IPersistFolder3 * iface,
1335 LPITEMIDLIST * pidl)
1337 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1339 TRACE ("(%p)->(%p)\n", This, pidl);
1341 if (!pidl) return E_POINTER;
1342 *pidl = ILClone (This->pidlRoot);
1346 /**************************************************************************
1347 * IFSFldr_PersistFolder3_InitializeEx
1349 * FIXME: error handling
1351 static HRESULT WINAPI
1352 IFSFldr_PersistFolder3_InitializeEx (IPersistFolder3 * iface,
1353 IBindCtx * pbc, LPCITEMIDLIST pidlRoot,
1354 const PERSIST_FOLDER_TARGET_INFO * ppfti)
1356 char sTemp[MAX_PATH];
1358 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1360 TRACE ("(%p)->(%p,%p,%p)\n", This, pbc, pidlRoot, ppfti);
1362 TRACE ("--%p %s %s 0x%08lx 0x%08x\n",
1363 ppfti->pidlTargetFolder, debugstr_w (ppfti->szTargetParsingName),
1364 debugstr_w (ppfti->szNetworkProvider), ppfti->dwAttributes,
1368 if (ppfti && ppfti->pidlTargetFolder)
1369 pdump (ppfti->pidlTargetFolder);
1372 __SHFreeAndNil (&This->pidlRoot); /* free the old */
1373 if (This->sPathTarget)
1374 __SHFreeAndNil (&This->sPathTarget);
1377 * Root path and pidl
1379 This->pidlRoot = ILClone (pidlRoot);
1382 * the target folder is spezified in csidl OR pidlTargetFolder OR
1383 * szTargetParsingName
1386 if (ppfti->csidl != -1) {
1387 if (SHGetSpecialFolderPathA (0, sTemp, ppfti->csidl,
1388 ppfti->csidl & CSIDL_FLAG_CREATE)) {
1389 __SHCloneStrA (&This->sPathTarget, sTemp);
1391 } else if (ppfti->szTargetParsingName[0]) {
1392 __SHCloneStrWtoA (&This->sPathTarget, ppfti->szTargetParsingName);
1393 } else if (ppfti->pidlTargetFolder) {
1394 if (SHGetPathFromIDListA (ppfti->pidlTargetFolder, sTemp)) {
1395 __SHCloneStrA (&This->sPathTarget, sTemp);
1400 TRACE ("--(%p)->(target=%s)\n", This, debugstr_a (This->sPathTarget));
1401 pdump (This->pidlRoot);
1402 return (This->sPathTarget) ? S_OK : E_FAIL;
1405 static HRESULT WINAPI
1406 IFSFldr_PersistFolder3_GetFolderTargetInfo (IPersistFolder3 * iface,
1407 PERSIST_FOLDER_TARGET_INFO * ppfti)
1409 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1410 FIXME ("(%p)->(%p)\n", This, ppfti);
1411 ZeroMemory (ppfti, sizeof (ppfti));
1415 static IPersistFolder3Vtbl vt_FSFldr_PersistFolder3 =
1417 IFSFldr_PersistFolder3_QueryInterface,
1418 IFSFldr_PersistFolder3_AddRef,
1419 IFSFldr_PersistFolder3_Release,
1420 IFSFldr_PersistFolder3_GetClassID,
1421 IFSFldr_PersistFolder3_Initialize,
1422 IFSFldr_PersistFolder3_fnGetCurFolder,
1423 IFSFldr_PersistFolder3_InitializeEx,
1424 IFSFldr_PersistFolder3_GetFolderTargetInfo
1427 /****************************************************************************
1428 * ISFDropTarget implementation
1431 ISFDropTarget_QueryDrop (IDropTarget * iface, DWORD dwKeyState,
1434 DWORD dwEffect = *pdwEffect;
1436 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1438 *pdwEffect = DROPEFFECT_NONE;
1440 if (This->fAcceptFmt) { /* Does our interpretation of the keystate ... */
1441 *pdwEffect = KeyStateToDropEffect (dwKeyState);
1443 /* ... matches the desired effect ? */
1444 if (dwEffect & *pdwEffect) {
1451 static HRESULT WINAPI
1452 ISFDropTarget_QueryInterface (IDropTarget * iface, REFIID riid, LPVOID * ppvObj)
1454 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1456 TRACE ("(%p)\n", This);
1458 return IUnknown_QueryInterface (This->pUnkOuter, riid, ppvObj);
1461 static ULONG WINAPI ISFDropTarget_AddRef (IDropTarget * iface)
1463 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1465 TRACE ("(%p)\n", This);
1467 return IUnknown_AddRef (This->pUnkOuter);
1470 static ULONG WINAPI ISFDropTarget_Release (IDropTarget * iface)
1472 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1474 TRACE ("(%p)\n", This);
1476 return IUnknown_Release (This->pUnkOuter);
1479 static HRESULT WINAPI
1480 ISFDropTarget_DragEnter (IDropTarget * iface, IDataObject * pDataObject,
1481 DWORD dwKeyState, POINTL pt, DWORD * pdwEffect)
1485 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1487 TRACE ("(%p)->(DataObject=%p)\n", This, pDataObject);
1489 InitFormatEtc (fmt, This->cfShellIDList, TYMED_HGLOBAL);
1491 This->fAcceptFmt = (S_OK == IDataObject_QueryGetData (pDataObject, &fmt)) ?
1494 ISFDropTarget_QueryDrop (iface, dwKeyState, pdwEffect);
1499 static HRESULT WINAPI
1500 ISFDropTarget_DragOver (IDropTarget * iface, DWORD dwKeyState, POINTL pt,
1503 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1505 TRACE ("(%p)\n", This);
1508 return E_INVALIDARG;
1510 ISFDropTarget_QueryDrop (iface, dwKeyState, pdwEffect);
1515 static HRESULT WINAPI ISFDropTarget_DragLeave (IDropTarget * iface)
1517 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1519 TRACE ("(%p)\n", This);
1521 This->fAcceptFmt = FALSE;
1526 static HRESULT WINAPI
1527 ISFDropTarget_Drop (IDropTarget * iface, IDataObject * pDataObject,
1528 DWORD dwKeyState, POINTL pt, DWORD * pdwEffect)
1530 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1532 FIXME ("(%p) object dropped\n", This);
1537 static struct IDropTargetVtbl dtvt = {
1538 ISFDropTarget_QueryInterface,
1539 ISFDropTarget_AddRef,
1540 ISFDropTarget_Release,
1541 ISFDropTarget_DragEnter,
1542 ISFDropTarget_DragOver,
1543 ISFDropTarget_DragLeave,