1 /* 2 * file system folder 3 * 4 * Copyright 1997 Marcus Meissner 5 * Copyright 1998, 1999, 2002 Juergen Schmied 6 * Copyright 2009 Andrew Hill 7 * 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. 12 * 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. 17 * 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 21 */ 22 23 #ifndef _CFSFOLDER_H_ 24 #define _CFSFOLDER_H_ 25 26 class CFSFolder : 27 public CComCoClass<CFSFolder, &CLSID_ShellFSFolder>, 28 public CComObjectRootEx<CComMultiThreadModelNoCS>, 29 public IShellFolder2, 30 public IPersistFolder3, 31 public IContextMenuCB, 32 public IShellFolderViewCB, 33 public IItemNameLimits 34 { 35 private: 36 const CLSID *m_pclsid; 37 38 /* both paths are parsible from the desktop */ 39 LPWSTR m_sPathTarget; /* complete path to target used for enumeration and ChangeNotify */ 40 41 LPITEMIDLIST m_pidlRoot; /* absolute pidl */ 42 43 DWORD m_bGroupPolicyActive; 44 HRESULT _CreateShellExtInstance(const CLSID *pclsid, LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut); 45 HRESULT _CreateExtensionUIObject(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut); 46 HRESULT _GetDropTarget(LPCITEMIDLIST pidl, LPVOID *ppvOut); 47 HRESULT _GetIconHandler(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut); 48 public: 49 CFSFolder(); 50 ~CFSFolder(); 51 52 // IShellFolder 53 virtual HRESULT WINAPI ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, DWORD *pchEaten, PIDLIST_RELATIVE *ppidl, DWORD *pdwAttributes); 54 virtual HRESULT WINAPI EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList); 55 virtual HRESULT WINAPI BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut); 56 virtual HRESULT WINAPI BindToStorage(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut); 57 virtual HRESULT WINAPI CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2); 58 virtual HRESULT WINAPI CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut); 59 virtual HRESULT WINAPI GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut); 60 virtual HRESULT WINAPI GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut); 61 virtual HRESULT WINAPI GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet); 62 virtual HRESULT WINAPI SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut); 63 64 /* ShellFolder2 */ 65 virtual HRESULT WINAPI GetDefaultSearchGUID(GUID *pguid); 66 virtual HRESULT WINAPI EnumSearches(IEnumExtraSearch **ppenum); 67 virtual HRESULT WINAPI GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG *pDisplay); 68 virtual HRESULT WINAPI GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags); 69 virtual HRESULT WINAPI GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv); 70 virtual HRESULT WINAPI GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd); 71 virtual HRESULT WINAPI MapColumnToSCID(UINT column, SHCOLUMNID *pscid); 72 73 // IPersist 74 virtual HRESULT WINAPI GetClassID(CLSID *lpClassId); 75 76 // IPersistFolder 77 virtual HRESULT WINAPI Initialize(PCIDLIST_ABSOLUTE pidl); 78 79 // IPersistFolder2 80 virtual HRESULT WINAPI GetCurFolder(PIDLIST_ABSOLUTE * pidl); 81 82 // IPersistFolder3 83 virtual HRESULT WINAPI InitializeEx(IBindCtx *pbc, LPCITEMIDLIST pidlRoot, const PERSIST_FOLDER_TARGET_INFO *ppfti); 84 virtual HRESULT WINAPI GetFolderTargetInfo(PERSIST_FOLDER_TARGET_INFO *ppfti); 85 86 // IContextMenuCB 87 virtual HRESULT WINAPI CallBack(IShellFolder *psf, HWND hwndOwner, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam); 88 89 // IShellFolderViewCB 90 virtual HRESULT WINAPI MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam); 91 92 /*** IItemNameLimits methods ***/ 93 94 STDMETHODIMP 95 GetMaxLength(LPCWSTR pszName, int *piMaxNameLen) 96 { 97 return E_NOTIMPL; 98 } 99 100 STDMETHODIMP 101 GetValidCharacters(LPWSTR *ppwszValidChars, LPWSTR *ppwszInvalidChars) 102 { 103 if (ppwszValidChars) 104 { 105 *ppwszValidChars = NULL; 106 } 107 if (ppwszInvalidChars) 108 { 109 SHStrDupW(INVALID_FILETITLE_CHARACTERSW, ppwszInvalidChars); 110 } 111 return S_OK; 112 } 113 114 DECLARE_REGISTRY_RESOURCEID(IDR_SHELLFSFOLDER) 115 DECLARE_NOT_AGGREGATABLE(CFSFolder) 116 117 DECLARE_PROTECT_FINAL_CONSTRUCT() 118 119 BEGIN_COM_MAP(CFSFolder) 120 COM_INTERFACE_ENTRY_IID(IID_IShellFolder2, IShellFolder2) 121 COM_INTERFACE_ENTRY_IID(IID_IShellFolder, IShellFolder) 122 COM_INTERFACE_ENTRY_IID(IID_IPersistFolder, IPersistFolder) 123 COM_INTERFACE_ENTRY_IID(IID_IPersistFolder2, IPersistFolder2) 124 COM_INTERFACE_ENTRY_IID(IID_IPersistFolder3, IPersistFolder3) 125 COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersist) 126 COM_INTERFACE_ENTRY_IID(IID_IShellFolderViewCB, IShellFolderViewCB) 127 COM_INTERFACE_ENTRY_IID(IID_IItemNameLimits, IItemNameLimits) 128 END_COM_MAP() 129 130 protected: 131 HRESULT WINAPI GetCustomViewInfo(ULONG unknown, SFVM_CUSTOMVIEWINFO_DATA *data); 132 }; 133 134 #endif /* _CFSFOLDER_H_ */ 135