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
);
28 CFileSysEnum should do an initial FindFirstFile and do a FindNextFile as each file is
29 returned by Next. When the enumerator is created, it can do numerous additional operations
30 including formatting a drive, reconnecting a network share drive, and requesting a disk
31 be inserted in a removable drive.
34 /***********************************************************************
35 * IShellFolder implementation
39 public CEnumIDListBase
45 HRESULT WINAPI
Initialize(LPWSTR sPathTarget
, DWORD dwFlags
);
47 BEGIN_COM_MAP(CFileSysEnum
)
48 COM_INTERFACE_ENTRY_IID(IID_IEnumIDList
, IEnumIDList
)
52 CFileSysEnum::CFileSysEnum()
56 CFileSysEnum::~CFileSysEnum()
60 HRESULT WINAPI
CFileSysEnum::Initialize(LPWSTR sPathTarget
, DWORD dwFlags
)
62 return CreateFolderEnumList(sPathTarget
, dwFlags
);
65 CFSFolder::CFSFolder()
67 pclsid
= (CLSID
*)&CLSID_ShellFSFolder
;
70 m_bGroupPolicyActive
= 0;
73 CFSFolder::~CFSFolder()
75 TRACE("-- destroying IShellFolder(%p)\n", this);
82 static const shvheader GenericSFHeader
[] = {
83 {IDS_SHV_COLUMN1
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_LEFT
, 15},
84 {IDS_SHV_COLUMN2
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
85 {IDS_SHV_COLUMN3
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_LEFT
, 10},
86 {IDS_SHV_COLUMN4
, SHCOLSTATE_TYPE_DATE
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_LEFT
, 12},
87 {IDS_SHV_COLUMN5
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_LEFT
, 10}
90 #define GENERICSHELLVIEWCOLUMNS 5
92 /**************************************************************************
93 * SHELL32_CreatePidlFromBindCtx [internal]
95 * If the caller bound File System Bind Data, assume it is the
96 * find data for the path.
97 * This allows binding of paths that don't exist.
99 LPITEMIDLIST
SHELL32_CreatePidlFromBindCtx(IBindCtx
*pbc
, LPCWSTR path
)
101 IFileSystemBindData
*fsbd
= NULL
;
102 LPITEMIDLIST pidl
= NULL
;
103 IUnknown
*param
= NULL
;
104 WIN32_FIND_DATAW wfd
;
107 TRACE("%p %s\n", pbc
, debugstr_w(path
));
112 /* see if the caller bound File System Bind Data */
113 r
= pbc
->GetObjectParam((LPOLESTR
)STR_FILE_SYS_BIND_DATA
, ¶m
);
117 r
= param
->QueryInterface(IID_PPV_ARG(IFileSystemBindData
,&fsbd
));
120 r
= fsbd
->GetFindData(&wfd
);
123 lstrcpynW(&wfd
.cFileName
[0], path
, MAX_PATH
);
124 pidl
= _ILCreateFromFindDataW(&wfd
);
132 /**************************************************************************
133 * CFSFolder::ParseDisplayName {SHELL32}
135 * Parse a display name.
138 * hwndOwner [in] Parent window for any message's
139 * pbc [in] optional FileSystemBindData context
140 * lpszDisplayName [in] Unicode displayname.
141 * pchEaten [out] (unicode) characters processed
142 * ppidl [out] complex pidl to item
143 * pdwAttributes [out] items attributes
146 * Every folder tries to parse only its own (the leftmost) pidl and creates a
147 * subfolder to evaluate the remaining parts.
148 * Now we can parse into namespaces implemented by shell extensions
150 * Behaviour on win98: lpszDisplayName=NULL -> crash
151 * lpszDisplayName="" -> returns mycoputer-pidl
154 * pdwAttributes is not set
155 * pchEaten is not set like in windows
157 HRESULT WINAPI
CFSFolder::ParseDisplayName(HWND hwndOwner
,
159 LPOLESTR lpszDisplayName
,
160 DWORD
*pchEaten
, PIDLIST_RELATIVE
*ppidl
,
161 DWORD
*pdwAttributes
)
163 HRESULT hr
= E_INVALIDARG
;
164 LPCWSTR szNext
= NULL
;
165 WCHAR szElement
[MAX_PATH
];
166 WCHAR szPath
[MAX_PATH
];
167 LPITEMIDLIST pidlTemp
= NULL
;
170 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
171 this, hwndOwner
, pbc
, lpszDisplayName
, debugstr_w (lpszDisplayName
),
172 pchEaten
, ppidl
, pdwAttributes
);
177 if (!lpszDisplayName
)
186 *pchEaten
= 0; /* strange but like the original */
188 if (*lpszDisplayName
)
190 /* get the next element */
191 szNext
= GetNextElementW (lpszDisplayName
, szElement
, MAX_PATH
);
193 pidlTemp
= SHELL32_CreatePidlFromBindCtx(pbc
, szElement
);
194 if (pidlTemp
!= NULL
)
196 /* We are creating an id list without ensuring that the items exist.
197 If we have a remaining path, this must be a folder.
198 We have to do it now because it is set as a file by default */
201 pidlTemp
->mkid
.abID
[0] = PT_FOLDER
;
207 /* build the full pathname to the element */
208 lstrcpynW(szPath
, sPathTarget
, MAX_PATH
- 1);
209 PathAddBackslashW(szPath
);
210 len
= wcslen(szPath
);
211 lstrcpynW(szPath
+ len
, szElement
, MAX_PATH
- len
);
214 hr
= _ILCreateFromPathW(szPath
, &pidlTemp
);
219 if (szNext
&& *szNext
)
221 /* try to analyse the next element */
222 hr
= SHELL32_ParseNextElement(this, hwndOwner
, pbc
,
223 &pidlTemp
, (LPOLESTR
) szNext
, pchEaten
, pdwAttributes
);
227 /* it's the last element */
228 if (pdwAttributes
&& *pdwAttributes
)
229 hr
= SHELL32_GetFSItemAttributes(this, pidlTemp
, pdwAttributes
);
239 TRACE("(%p)->(-- pidl=%p ret=0x%08x)\n", this, ppidl
? *ppidl
: 0, hr
);
244 /**************************************************************************
245 * CFSFolder::EnumObjects
247 * HWND hwndOwner, //[in ] Parent Window
248 * DWORD grfFlags, //[in ] SHCONTF enumeration mask
249 * LPENUMIDLIST* ppenumIDList //[out] IEnumIDList interface
251 HRESULT WINAPI
CFSFolder::EnumObjects(
254 LPENUMIDLIST
*ppEnumIDList
)
256 return ShellObjectCreatorInit
<CFileSysEnum
>(sPathTarget
, dwFlags
, IID_IEnumIDList
, ppEnumIDList
);
259 /**************************************************************************
260 * CFSFolder::BindToObject
262 * LPCITEMIDLIST pidl, //[in ] relative pidl to open
263 * LPBC pbc, //[in ] optional FileSystemBindData context
264 * REFIID riid, //[in ] Initial Interface
265 * LPVOID* ppvObject //[out] Interface*
267 HRESULT WINAPI
CFSFolder::BindToObject(
268 PCUIDLIST_RELATIVE pidl
,
273 TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", this, pidl
, pbc
,
274 shdebugstr_guid(&riid
), ppvOut
);
276 return SHELL32_BindToFS(pidlRoot
, sPathTarget
, pidl
, riid
, ppvOut
);
279 /**************************************************************************
280 * CFSFolder::BindToStorage
282 * LPCITEMIDLIST pidl, //[in ] complex pidl to store
283 * LPBC pbc, //[in ] reserved
284 * REFIID riid, //[in ] Initial storage interface
285 * LPVOID* ppvObject //[out] Interface* returned
287 HRESULT WINAPI
CFSFolder::BindToStorage(
288 PCUIDLIST_RELATIVE pidl
,
293 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", this, pidl
, pbcReserved
,
294 shdebugstr_guid (&riid
), ppvOut
);
300 /**************************************************************************
301 * CFSFolder::CompareIDs
304 HRESULT WINAPI
CFSFolder::CompareIDs(LPARAM lParam
,
305 PCUIDLIST_RELATIVE pidl1
,
306 PCUIDLIST_RELATIVE pidl2
)
308 LPPIDLDATA pData1
= _ILGetDataPointer(pidl1
);
309 LPPIDLDATA pData2
= _ILGetDataPointer(pidl2
);
310 FileStructW
* pDataW1
= _ILGetFileStructW(pidl1
);
311 FileStructW
* pDataW2
= _ILGetFileStructW(pidl2
);
312 BOOL bIsFolder1
= _ILIsFolder(pidl1
);
313 BOOL bIsFolder2
= _ILIsFolder(pidl2
);
314 LPWSTR pExtension1
, pExtension2
;
316 if (!pDataW1
|| !pDataW2
|| LOWORD(lParam
) >= GENERICSHELLVIEWCOLUMNS
)
319 /* When sorting between a File and a Folder, the Folder gets sorted first */
320 if (bIsFolder1
!= bIsFolder2
)
322 return MAKE_COMPARE_HRESULT(bIsFolder1
? -1 : 1);
326 switch (LOWORD(lParam
))
329 result
= wcsicmp(pDataW1
->wszName
, pDataW2
->wszName
);
332 pExtension1
= PathFindExtensionW(pDataW1
->wszName
);
333 pExtension2
= PathFindExtensionW(pDataW2
->wszName
);
334 result
= wcsicmp(pExtension1
, pExtension2
);
337 result
= pData1
->u
.file
.dwFileSize
- pData2
->u
.file
.dwFileSize
;
339 case 3: /* Modified */
340 result
= pData1
->u
.file
.uFileDate
- pData2
->u
.file
.uFileDate
;
342 result
= pData1
->u
.file
.uFileTime
- pData2
->u
.file
.uFileTime
;
344 case 4: /* Attributes */
345 return SHELL32_CompareDetails(this, lParam
, pidl1
, pidl2
);
349 return SHELL32_CompareChildren(this, lParam
, pidl1
, pidl2
);
351 return MAKE_COMPARE_HRESULT(result
);
354 /**************************************************************************
355 * CFSFolder::CreateViewObject
357 HRESULT WINAPI
CFSFolder::CreateViewObject(HWND hwndOwner
,
358 REFIID riid
, LPVOID
* ppvOut
)
360 CComPtr
<IShellView
> pShellView
;
361 HRESULT hr
= E_INVALIDARG
;
363 TRACE ("(%p)->(hwnd=%p,%s,%p)\n", this, hwndOwner
, shdebugstr_guid (&riid
),
370 if (IsEqualIID (riid
, IID_IDropTarget
))
371 hr
= CFSDropTarget_CreateInstance(sPathTarget
, riid
, ppvOut
);
372 else if (IsEqualIID (riid
, IID_IContextMenu
))
374 FIXME ("IContextMenu not implemented\n");
377 else if (IsEqualIID (riid
, IID_IShellView
))
379 hr
= CDefView_Constructor(this, riid
, ppvOut
);
382 TRACE("-- (%p)->(interface=%p)\n", this, ppvOut
);
386 /**************************************************************************
387 * CFSFolder::GetAttributesOf
390 * UINT cidl, //[in ] num elements in pidl array
391 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
392 * ULONG* rgfInOut) //[out] result array
395 HRESULT WINAPI
CFSFolder::GetAttributesOf(UINT cidl
,
396 PCUITEMID_CHILD_ARRAY apidl
, DWORD
* rgfInOut
)
410 LPCITEMIDLIST rpidl
= ILFindLastID(pidlRoot
);
412 if (_ILIsFolder(rpidl
) || _ILIsValue(rpidl
))
414 SHELL32_GetFSItemAttributes(this, rpidl
, rgfInOut
);
416 else if (_ILIsDrive(rpidl
))
418 IShellFolder
*psfParent
= NULL
;
419 hr
= SHBindToParent(pidlRoot
, IID_PPV_ARG(IShellFolder
, &psfParent
), NULL
);
422 hr
= psfParent
->GetAttributesOf(1, &rpidl
, (SFGAOF
*)rgfInOut
);
423 psfParent
->Release();
428 ERR("Got and unknown pidl!\n");
433 while (cidl
> 0 && *apidl
)
436 if(_ILIsFolder(*apidl
) || _ILIsValue(*apidl
))
437 SHELL32_GetFSItemAttributes(this, *apidl
, rgfInOut
);
439 ERR("Got an unknown type of pidl!!!\n");
444 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
445 *rgfInOut
&= ~SFGAO_VALIDATE
;
447 TRACE("-- result=0x%08x\n", *rgfInOut
);
452 /**************************************************************************
453 * CFSFolder::GetUIObjectOf
456 * HWND hwndOwner, //[in ] Parent window for any output
457 * UINT cidl, //[in ] array size
458 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
459 * REFIID riid, //[in ] Requested Interface
460 * UINT* prgfInOut, //[ ] reserved
461 * LPVOID* ppvObject) //[out] Resulting Interface
464 * This function gets asked to return "view objects" for one or more (multiple
466 * The viewobject typically is an COM object with one of the following
468 * IExtractIcon,IDataObject,IContextMenu
469 * In order to support icon positions in the default Listview your DataObject
470 * must implement the SetData method (in addition to GetData :) - the shell
471 * passes a barely documented "Icon positions" structure to SetData when the
472 * drag starts, and GetData's it if the drop is in another explorer window that
473 * needs the positions.
475 HRESULT WINAPI
CFSFolder::GetUIObjectOf(HWND hwndOwner
,
476 UINT cidl
, PCUITEMID_CHILD_ARRAY apidl
,
477 REFIID riid
, UINT
* prgfInOut
,
481 HRESULT hr
= E_INVALIDARG
;
483 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
484 this, hwndOwner
, cidl
, apidl
, shdebugstr_guid (&riid
), prgfInOut
, ppvOut
);
490 if (IsEqualIID(riid
, IID_IContextMenu
) && (cidl
>= 1))
492 IContextMenu
* pCm
= NULL
;
495 AddFSClassKeysToArray(apidl
[0], hKeys
, &cKeys
);
496 hr
= CDefFolderMenu_Create2(pidlRoot
, hwndOwner
, cidl
, apidl
, static_cast<IShellFolder
*>(this), NULL
, cKeys
, hKeys
, &pCm
);
499 else if (IsEqualIID (riid
, IID_IDataObject
))
503 hr
= IDataObject_Constructor (hwndOwner
, pidlRoot
, apidl
, cidl
, (IDataObject
**)&pObj
);
507 hr
= IDataObject_Constructor (hwndOwner
, pidlRoot
, (LPCITEMIDLIST
*)&pidlRoot
, 1, (IDataObject
**)&pObj
);
510 else if ((IsEqualIID (riid
, IID_IExtractIconA
) || IsEqualIID (riid
, IID_IExtractIconW
)) && (cidl
== 1))
512 hr
= CFSExtractIcon_CreateInstance(this, apidl
[0], riid
, &pObj
);
514 else if (IsEqualIID (riid
, IID_IDropTarget
))
516 /* only interested in attempting to bind to shell folders, not files (except exe), so if we fail, rebind to root */
517 if (cidl
!= 1 || FAILED(hr
= this->_GetDropTarget(apidl
[0], (LPVOID
*) &pObj
)))
519 IDropTarget
* pDt
= NULL
;
520 hr
= CFSDropTarget_CreateInstance(sPathTarget
, riid
, ppvOut
);
524 else if ((IsEqualIID(riid
, IID_IShellLinkW
) ||
525 IsEqualIID(riid
, IID_IShellLinkA
)) && (cidl
== 1))
527 hr
= IShellLink_ConstructFromFile(this, apidl
[0], riid
, &pObj
);
532 if (SUCCEEDED(hr
) && !pObj
)
537 TRACE("(%p)->hr=0x%08x\n", this, hr
);
541 static const WCHAR AdvancedW
[] = L
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced";
542 static const WCHAR HideFileExtW
[] = L
"HideFileExt";
543 static const WCHAR NeverShowExtW
[] = L
"NeverShowExt";
545 /******************************************************************************
546 * SHELL_FS_HideExtension [Internal]
548 * Query the registry if the filename extension of a given path should be
552 * szPath [I] Relative or absolute path of a file
555 * TRUE, if the filename's extension should be hidden
558 BOOL
SHELL_FS_HideExtension(LPWSTR szPath
)
562 DWORD dwDataSize
= sizeof (DWORD
);
563 BOOL doHide
= FALSE
; /* The default value is FALSE (win98 at least) */
565 if (!RegCreateKeyExW(HKEY_CURRENT_USER
, AdvancedW
, 0, 0, 0, KEY_ALL_ACCESS
, 0, &hKey
, 0)) {
566 if (!RegQueryValueExW(hKey
, HideFileExtW
, 0, 0, (LPBYTE
) &dwData
, &dwDataSize
))
572 LPWSTR ext
= PathFindExtensionW(szPath
);
575 WCHAR classname
[MAX_PATH
];
576 LONG classlen
= sizeof(classname
);
578 if (!RegQueryValueW(HKEY_CLASSES_ROOT
, ext
, classname
, &classlen
))
579 if (!RegOpenKeyW(HKEY_CLASSES_ROOT
, classname
, &hKey
)) {
580 if (!RegQueryValueExW(hKey
, NeverShowExtW
, 0, NULL
, NULL
, NULL
))
589 void SHELL_FS_ProcessDisplayFilename(LPWSTR szPath
, DWORD dwFlags
)
591 /*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */
592 if (!(dwFlags
& SHGDN_FORPARSING
) &&
593 ((dwFlags
& SHGDN_INFOLDER
) || (dwFlags
== SHGDN_NORMAL
))) {
594 if (SHELL_FS_HideExtension(szPath
) && szPath
[0] != '.')
595 PathRemoveExtensionW(szPath
);
599 /**************************************************************************
600 * CFSFolder::GetDisplayNameOf
601 * Retrieves the display name for the specified file object or subfolder
604 * LPCITEMIDLIST pidl, //[in ] complex pidl to item
605 * DWORD dwFlags, //[in ] SHGNO formatting flags
606 * LPSTRRET lpName) //[out] Returned display name
609 * if the name is in the pidl the ret value should be a STRRET_OFFSET
612 HRESULT WINAPI
CFSFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl
,
613 DWORD dwFlags
, LPSTRRET strRet
)
615 if (!pidl
|| !strRet
)
618 /* If it is a complex pidl, let the child handle it */
619 if (!_ILIsPidlSimple (pidl
)) /* complex pidl */
621 return SHELL32_GetDisplayNameOfChild(this, pidl
, dwFlags
, strRet
);
623 else if (!pidl
->mkid
.cb
) /* empty pidl */
625 /* If it is an empty pidl return only the path of the folder */
626 if ((GET_SHGDN_FOR(dwFlags
) & SHGDN_FORPARSING
) &&
627 (GET_SHGDN_RELATION(dwFlags
) != SHGDN_INFOLDER
) &&
630 return SHSetStrRet(strRet
, sPathTarget
);
636 LPWSTR pszPath
= (LPWSTR
)CoTaskMemAlloc((MAX_PATH
+ 1) * sizeof(WCHAR
));
638 return E_OUTOFMEMORY
;
640 if ((GET_SHGDN_FOR(dwFlags
) & SHGDN_FORPARSING
) &&
641 (GET_SHGDN_RELATION(dwFlags
) != SHGDN_INFOLDER
) &&
644 lstrcpynW(pszPath
, sPathTarget
, MAX_PATH
);
645 PathAddBackslashW(pszPath
);
646 len
= wcslen(pszPath
);
648 _ILSimpleGetTextW(pidl
, pszPath
+ len
, MAX_PATH
+ 1 - len
);
649 if (!_ILIsFolder(pidl
)) SHELL_FS_ProcessDisplayFilename(pszPath
, dwFlags
);
651 strRet
->uType
= STRRET_WSTR
;
652 strRet
->pOleStr
= pszPath
;
654 TRACE ("-- (%p)->(%s)\n", this, strRet
->uType
== STRRET_CSTR
? strRet
->cStr
: debugstr_w(strRet
->pOleStr
));
658 /**************************************************************************
659 * CFSFolder::SetNameOf
660 * Changes the name of a file object or subfolder, possibly changing its item
661 * identifier in the process.
664 * HWND hwndOwner, //[in ] Owner window for output
665 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
666 * LPCOLESTR lpszName, //[in ] the items new display name
667 * DWORD dwFlags, //[in ] SHGNO formatting flags
668 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
670 HRESULT WINAPI
CFSFolder::SetNameOf(
672 PCUITEMID_CHILD pidl
,
675 PITEMID_CHILD
*pPidlOut
)
677 WCHAR szSrc
[MAX_PATH
+ 1], szDest
[MAX_PATH
+ 1];
679 BOOL bIsFolder
= _ILIsFolder (ILFindLastID (pidl
));
681 TRACE ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", this, hwndOwner
, pidl
,
682 debugstr_w (lpName
), dwFlags
, pPidlOut
);
684 /* build source path */
685 lstrcpynW(szSrc
, sPathTarget
, MAX_PATH
);
686 ptr
= PathAddBackslashW (szSrc
);
688 _ILSimpleGetTextW (pidl
, ptr
, MAX_PATH
+ 1 - (ptr
- szSrc
));
690 /* build destination path */
691 if (dwFlags
== SHGDN_NORMAL
|| dwFlags
& SHGDN_INFOLDER
) {
692 lstrcpynW(szDest
, sPathTarget
, MAX_PATH
);
693 ptr
= PathAddBackslashW (szDest
);
695 lstrcpynW(ptr
, lpName
, MAX_PATH
+ 1 - (ptr
- szDest
));
697 lstrcpynW(szDest
, lpName
, MAX_PATH
);
699 if(!(dwFlags
& SHGDN_FORPARSING
) && SHELL_FS_HideExtension(szSrc
)) {
700 WCHAR
*ext
= PathFindExtensionW(szSrc
);
702 INT len
= wcslen(szDest
);
703 lstrcpynW(szDest
+ len
, ext
, MAX_PATH
- len
);
707 TRACE ("src=%s dest=%s\n", debugstr_w(szSrc
), debugstr_w(szDest
));
708 if (!memcmp(szSrc
, szDest
, (wcslen(szDest
) + 1) * sizeof(WCHAR
)))
710 /* src and destination is the same */
713 hr
= _ILCreateFromPathW(szDest
, pPidlOut
);
719 if (MoveFileW (szSrc
, szDest
))
724 hr
= _ILCreateFromPathW(szDest
, pPidlOut
);
726 SHChangeNotify (bIsFolder
? SHCNE_RENAMEFOLDER
: SHCNE_RENAMEITEM
,
727 SHCNF_PATHW
, szSrc
, szDest
);
735 HRESULT WINAPI
CFSFolder::GetDefaultSearchGUID(GUID
* pguid
)
737 FIXME ("(%p)\n", this);
741 HRESULT WINAPI
CFSFolder::EnumSearches(IEnumExtraSearch
** ppenum
)
743 FIXME ("(%p)\n", this);
747 HRESULT WINAPI
CFSFolder::GetDefaultColumn(DWORD dwRes
,
748 ULONG
* pSort
, ULONG
* pDisplay
)
750 TRACE ("(%p)\n", this);
760 HRESULT WINAPI
CFSFolder::GetDefaultColumnState(UINT iColumn
,
763 TRACE ("(%p)\n", this);
765 if (!pcsFlags
|| iColumn
>= GENERICSHELLVIEWCOLUMNS
)
768 *pcsFlags
= GenericSFHeader
[iColumn
].pcsFlags
;
773 HRESULT WINAPI
CFSFolder::GetDetailsEx(PCUITEMID_CHILD pidl
,
774 const SHCOLUMNID
* pscid
, VARIANT
* pv
)
776 FIXME ("(%p)\n", this);
781 HRESULT WINAPI
CFSFolder::GetDetailsOf(PCUITEMID_CHILD pidl
,
782 UINT iColumn
, SHELLDETAILS
* psd
)
786 TRACE ("(%p)->(%p %i %p)\n", this, pidl
, iColumn
, psd
);
788 if (!psd
|| iColumn
>= GENERICSHELLVIEWCOLUMNS
)
793 /* the header titles */
794 psd
->fmt
= GenericSFHeader
[iColumn
].fmt
;
795 psd
->cxChar
= GenericSFHeader
[iColumn
].cxChar
;
796 return SHSetStrRet(&psd
->str
, GenericSFHeader
[iColumn
].colnameid
);
801 psd
->str
.uType
= STRRET_CSTR
;
802 /* the data from the pidl */
806 hr
= GetDisplayNameOf (pidl
,
807 SHGDN_NORMAL
| SHGDN_INFOLDER
, &psd
->str
);
810 _ILGetFileSize(pidl
, psd
->str
.cStr
, MAX_PATH
);
813 _ILGetFileType(pidl
, psd
->str
.cStr
, MAX_PATH
);
816 _ILGetFileDate(pidl
, psd
->str
.cStr
, MAX_PATH
);
818 case 4: /* attributes */
819 _ILGetFileAttributes(pidl
, psd
->str
.cStr
, MAX_PATH
);
827 HRESULT WINAPI
CFSFolder::MapColumnToSCID (UINT column
,
830 FIXME ("(%p)\n", this);
834 /************************************************************************
835 * CFSFolder::GetClassID
837 HRESULT WINAPI
CFSFolder::GetClassID(CLSID
* lpClassId
)
839 TRACE ("(%p)\n", this);
844 *lpClassId
= *pclsid
;
849 /************************************************************************
850 * CFSFolder::Initialize
853 * sPathTarget is not set. Don't know how to handle in a non rooted environment.
855 HRESULT WINAPI
CFSFolder::Initialize(LPCITEMIDLIST pidl
)
857 WCHAR wszTemp
[MAX_PATH
];
859 TRACE ("(%p)->(%p)\n", this, pidl
);
861 SHFree (pidlRoot
); /* free the old pidl */
862 pidlRoot
= ILClone (pidl
); /* set my pidl */
864 SHFree (sPathTarget
);
868 if (SHGetPathFromIDListW (pidl
, wszTemp
))
870 int len
= wcslen(wszTemp
);
871 sPathTarget
= (WCHAR
*)SHAlloc((len
+ 1) * sizeof(WCHAR
));
873 return E_OUTOFMEMORY
;
874 memcpy(sPathTarget
, wszTemp
, (len
+ 1) * sizeof(WCHAR
));
877 TRACE ("--(%p)->(%s)\n", this, debugstr_w(sPathTarget
));
881 /**************************************************************************
882 * CFSFolder::GetCurFolder
884 HRESULT WINAPI
CFSFolder::GetCurFolder(LPITEMIDLIST
* pidl
)
886 TRACE ("(%p)->(%p)\n", this, pidl
);
891 *pidl
= ILClone(pidlRoot
);
895 /**************************************************************************
896 * CFSFolder::InitializeEx
898 * FIXME: error handling
900 HRESULT WINAPI
CFSFolder::InitializeEx(IBindCtx
* pbc
, LPCITEMIDLIST pidlRootx
,
901 const PERSIST_FOLDER_TARGET_INFO
* ppfti
)
903 WCHAR wszTemp
[MAX_PATH
];
905 TRACE("(%p)->(%p,%p,%p)\n", this, pbc
, pidlRootx
, ppfti
);
907 TRACE("--%p %s %s 0x%08x 0x%08x\n",
908 ppfti
->pidlTargetFolder
, debugstr_w (ppfti
->szTargetParsingName
),
909 debugstr_w (ppfti
->szNetworkProvider
), ppfti
->dwAttributes
,
913 if (ppfti
&& ppfti
->pidlTargetFolder
)
914 pdump(ppfti
->pidlTargetFolder
);
917 __SHFreeAndNil(&pidlRoot
); /* free the old */
919 __SHFreeAndNil(&sPathTarget
);
924 pidlRoot
= ILClone(pidlRootx
);
927 * the target folder is spezified in csidl OR pidlTargetFolder OR
928 * szTargetParsingName
932 if (ppfti
->csidl
!= -1)
934 if (SHGetSpecialFolderPathW(0, wszTemp
, ppfti
->csidl
,
935 ppfti
->csidl
& CSIDL_FLAG_CREATE
)) {
936 int len
= wcslen(wszTemp
);
937 sPathTarget
= (WCHAR
*)SHAlloc((len
+ 1) * sizeof(WCHAR
));
939 return E_OUTOFMEMORY
;
940 memcpy(sPathTarget
, wszTemp
, (len
+ 1) * sizeof(WCHAR
));
943 else if (ppfti
->szTargetParsingName
[0])
945 int len
= wcslen(ppfti
->szTargetParsingName
);
946 sPathTarget
= (WCHAR
*)SHAlloc((len
+ 1) * sizeof(WCHAR
));
948 return E_OUTOFMEMORY
;
949 memcpy(sPathTarget
, ppfti
->szTargetParsingName
,
950 (len
+ 1) * sizeof(WCHAR
));
952 else if (ppfti
->pidlTargetFolder
)
954 if (SHGetPathFromIDListW(ppfti
->pidlTargetFolder
, wszTemp
))
956 int len
= wcslen(wszTemp
);
957 sPathTarget
= (WCHAR
*)SHAlloc((len
+ 1) * sizeof(WCHAR
));
959 return E_OUTOFMEMORY
;
960 memcpy(sPathTarget
, wszTemp
, (len
+ 1) * sizeof(WCHAR
));
965 TRACE("--(%p)->(target=%s)\n", this, debugstr_w(sPathTarget
));
967 return (sPathTarget
) ? S_OK
: E_FAIL
;
970 HRESULT WINAPI
CFSFolder::GetFolderTargetInfo(PERSIST_FOLDER_TARGET_INFO
* ppfti
)
972 FIXME("(%p)->(%p)\n", this, ppfti
);
973 ZeroMemory(ppfti
, sizeof (*ppfti
));
977 HRESULT WINAPI
CFSFolder::_GetDropTarget(LPCITEMIDLIST pidl
, LPVOID
*ppvOut
) {
981 TRACE("CFSFolder::_GetDropTarget entered\n");
983 if (_ILIsFolder (pidl
))
985 CComPtr
<IShellFolder
> psfChild
;
986 hr
= this->BindToObject(pidl
, NULL
, IID_PPV_ARG(IShellFolder
, &psfChild
));
987 if (FAILED_UNEXPECTEDLY(hr
))
990 return psfChild
->CreateViewObject(NULL
, IID_IDropTarget
, ppvOut
);
994 hr
= this->GetDisplayNameOf(pidl
, SHGDN_FORPARSING
, &strFile
);
997 WCHAR wszPath
[MAX_PATH
];
998 hr
= StrRetToBufW(&strFile
, pidl
, wszPath
, _countof(wszPath
));
1002 LPCWSTR pwszExt
= PathFindExtensionW(wszPath
);
1005 /* enumerate dynamic/static for a given file class */
1006 if (RegOpenKeyExW(HKEY_CLASSES_ROOT
, pwszExt
, 0, KEY_READ
, &hKey
) == ERROR_SUCCESS
)
1008 /* load dynamic extensions from file extension key, for example .jpg */
1009 _LoadDynamicDropTargetHandlerForKey(hKey
, wszPath
, ppvOut
);
1014 DWORD dwSize
= sizeof(wszTemp
);
1015 if (RegGetValueW(HKEY_CLASSES_ROOT
, pwszExt
, NULL
, RRF_RT_REG_SZ
, NULL
, wszTemp
, &dwSize
) == ERROR_SUCCESS
)
1017 if (RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszTemp
, 0, KEY_READ
, &hKey
) == ERROR_SUCCESS
)
1019 /* load dynamic extensions from progid key, for example jpegfile */
1020 _LoadDynamicDropTargetHandlerForKey(hKey
, wszPath
, ppvOut
);
1028 ERR("GetDisplayNameOf failed: %x\n", hr
);
1033 HRESULT WINAPI
CFSFolder::_LoadDynamicDropTargetHandlerForKey(HKEY hRootKey
, LPCWSTR pwcsname
, LPVOID
*ppvOut
)
1035 TRACE("CFSFolder::_LoadDynamicDropTargetHandlerForKey entered\n");
1037 WCHAR wszName
[MAX_PATH
], *pwszClsid
;
1038 DWORD dwSize
= sizeof(wszName
);
1041 if (RegGetValueW(hRootKey
, L
"shellex\\DropHandler", NULL
, RRF_RT_REG_SZ
, NULL
, wszName
, &dwSize
) == ERROR_SUCCESS
)
1044 hr
= CLSIDFromString(wszName
, &clsid
);
1046 pwszClsid
= wszName
;
1048 if (m_bGroupPolicyActive
)
1050 if (RegGetValueW(HKEY_LOCAL_MACHINE
,
1051 L
"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved",
1056 NULL
) == ERROR_SUCCESS
)
1058 hr
= _LoadDynamicDropTargetHandler(&clsid
, pwcsname
, ppvOut
);
1063 hr
= _LoadDynamicDropTargetHandler(&clsid
, pwcsname
, ppvOut
);
1071 HRESULT WINAPI
CFSFolder::_LoadDynamicDropTargetHandler(const CLSID
*pclsid
, LPCWSTR pwcsname
, LPVOID
*ppvOut
)
1073 TRACE("CFSFolder::_LoadDynamicDropTargetHandler entered\n");
1076 CComPtr
<IPersistFile
> pp
;
1077 hr
= SHCoCreateInstance(NULL
, pclsid
, NULL
, IID_PPV_ARG(IPersistFile
, &pp
));
1080 ERR("SHCoCreateInstance failed %x\n", GetLastError());
1082 pp
->Load(pwcsname
, 0);
1084 hr
= pp
->QueryInterface(IID_PPV_ARG(IDropTarget
, (IDropTarget
**) ppvOut
));
1087 ERR("Failed to query for interface IID_IShellExtInit hr %x pclsid %s\n", hr
, wine_dbgstr_guid(pclsid
));