Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

535 lines
24 KiB

  1. #include "fstreex.h" // public stuff
  2. #include "filetbl.h"
  3. #include <caggunk.h>
  4. #include <idhidden.h>
  5. #include "lmcons.h"
  6. #include "pidl.h"
  7. #include <enumt.h>
  8. class CFSDropTarget;
  9. class CFSFolderViewCB;
  10. class CFileSysEnum;
  11. class CFSFolderEnumSTATSTG;
  12. class CFSFolder;
  13. class CFileSysItemString;
  14. #define INDEX_PROPERTYBAG_HKCU 0
  15. #define INDEX_PROPERTYBAG_HKLM 1
  16. #define INDEX_PROPERTYBAG_DESKTOPINI 2
  17. class CFSFolderPropertyBag : public IPropertyBag
  18. {
  19. friend CFSFolder;
  20. public:
  21. // IUnknown
  22. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  23. STDMETHODIMP_(ULONG) AddRef();
  24. STDMETHODIMP_(ULONG) Release();
  25. // IPropertyBag
  26. STDMETHODIMP Read(LPCOLESTR pszPropName, VARIANT *pVar, IErrorLog *pErrorLog);
  27. STDMETHODIMP Write(LPCOLESTR pszPropName, VARIANT *pVar);
  28. protected:
  29. CFSFolderPropertyBag(CFSFolder *pff, DWORD grfMode);
  30. HRESULT _Init(LPCIDFOLDER pidfLast);
  31. private:
  32. virtual ~CFSFolderPropertyBag();
  33. LONG _cRef;
  34. DWORD _grfMode;
  35. CFSFolder* _pFSFolder;
  36. IPropertyBag* _pPropertyBags[3];
  37. };
  38. #define UASTROFFW(pfsi, cb) (LPNWSTR)(((LPBYTE)(pfsi)) + (cb))
  39. #define UASTROFFA(pfsi, cb) (LPSTR)(((LPBYTE)(pfsi)) + (cb))
  40. // This enum is simply an index into c_rgFolderType and c_wvContent (TODO: merge these),
  41. // therefore this *is* the Folder Type:
  42. typedef enum {
  43. FVCBFT_NOTSPECIFIED = -1,
  44. FVCBFT_DOCUMENTS = 0, // "0" is default until otherwise specified
  45. FVCBFT_MYDOCUMENTS,
  46. FVCBFT_PICTURES,
  47. FVCBFT_MYPICTURES,
  48. FVCBFT_PHOTOALBUM,
  49. FVCBFT_MUSIC,
  50. FVCBFT_MYMUSIC,
  51. FVCBFT_MUSICARTIST,
  52. FVCBFT_MUSICALBUM,
  53. FVCBFT_VIDEOS,
  54. FVCBFT_MYVIDEOS,
  55. FVCBFT_VIDEOALBUM,
  56. FVCBFT_USELEGACYHTT,
  57. FVCBFT_COMMONDOCUMENTS,
  58. FVCBFT_NUM_FOLDERTYPES
  59. } FVCBFOLDERTYPE;
  60. typedef enum
  61. {
  62. FSINAME_NONE = 0x0000,
  63. FSINAME_FS = 0x0001,
  64. FSINAME_UI = 0x0002,
  65. FSINAME_FSUI = 0x0003,
  66. FSINAME_RESOURCE = 0x0004,
  67. FSINAME_CLASS = 0x0008,
  68. } FSINAME;
  69. class CFileSysItem
  70. {
  71. public:
  72. CFileSysItem(LPCIDFOLDER pidf);
  73. BOOL HasResourceName() { return ((_pidfx && _pidfx->offResourceA)); }
  74. BOOL IsLegacy() { return _pidfx == NULL; }
  75. BOOL CantRename(CFSFolder *pfs);
  76. LPCWSTR MayCopyFSName(BOOL fMustCopy, LPWSTR psz, DWORD cch);
  77. LPCWSTR MayCopyClassName(BOOL fMustCopy, LPTSTR pszClass, UINT cch);
  78. protected: // methods
  79. TRIBIT _IsMine(CFSFolder *pfs);
  80. BOOL _IsPersonalized();
  81. protected: // members
  82. LPCIDFOLDER _pidf;
  83. PCIDFOLDEREX _pidfx;
  84. PCIDPERSONALIZED _pidp;
  85. };
  86. class CFileSysItemString : public CFileSysItem
  87. {
  88. public:
  89. CFileSysItemString(LPCIDFOLDER pidf);
  90. LPCWSTR FSName();
  91. LPCSTR AltName();
  92. LPCWSTR UIName(CFSFolder *pfs);
  93. LPCWSTR ResourceName();
  94. LPCWSTR Class();
  95. HRESULT GetFindData(WIN32_FIND_DATAW *pfd);
  96. HRESULT GetFindDataSimple(WIN32_FIND_DATAW *pfd);
  97. BOOL ShowExtension(BOOL fDefShowExt);
  98. PERCEIVED PerceivedType();
  99. BOOL IsShimgvwImage();
  100. BOOL GetJunctionClsid(CLSID *pclsid, BOOL fShellExtOk);
  101. HRESULT AssocCreate(CFSFolder *pfs, BOOL fForCtxMenu, REFIID riid, void **ppv);
  102. DWORD ClassFlags(BOOL fNeedsIconBits)
  103. { return _ClassFlags(NULL, fNeedsIconBits); }
  104. protected: // methods
  105. BOOL _LoadResource(CFSFolder *pfs);
  106. BOOL _MakePossessiveName(LPCWSTR pszFormat);
  107. int _GetPersonalizedRes(int csidl, BOOL fIsMine);
  108. void _FormatTheirs(LPCWSTR pszFormat);
  109. BOOL _ResourceName(LPWSTR psz, DWORD cch, BOOL fIsTheirs);
  110. LPCWSTR _Class();
  111. DWORD _ClassFlags(IUnknown *punkAssoc, BOOL fNeedsIconBits);
  112. void _QueryClassFlags(IAssociationArray *paa);
  113. void _QueryIconIndex(IAssociationArray *paa);
  114. protected: // members
  115. LPCWSTR _pszFSName; // points inside the pidfx
  116. LPCWSTR _pszUIName; // points inside the pidfx
  117. LPCWSTR _pszClass; // points inside the pidfx
  118. DWORD _dwClass;
  119. FSINAME _fsin;
  120. WCHAR _sz[MAX_PATH];
  121. };
  122. class CFSAssocEnumData : public CEnumAssociationElements
  123. {
  124. public:
  125. CFSAssocEnumData(BOOL fIsUnknown, CFSFolder *pfs, LPCIDFOLDER pidf);
  126. ~CFSAssocEnumData() { if (_pidl) ILFree(_pidl); }
  127. protected:
  128. virtual BOOL _Next(IAssociationElement **ppae);
  129. protected:
  130. BOOL _fIsUnknown;
  131. BOOL _fIsSystemFolder;
  132. WCHAR _szPath[MAX_PATH];
  133. LPITEMIDLIST _pidl;
  134. };
  135. // This struct is used for caching the column info
  136. typedef struct {
  137. SHCOLUMNINFO shci;
  138. IColumnProvider *pcp;
  139. UINT iColumnId; // This is the 'real' column number, think of it as an index to the scid, which can be provided multiple times
  140. // ie 3 column handlers each provide the same 5 cols, this goes from 0-4
  141. } COLUMNLISTENTRY;
  142. typedef struct
  143. {
  144. UINT cbResource;
  145. CHAR szResource[MAX_PATH];
  146. IDPERSONALIZED idp;
  147. } EXSTRINGS;
  148. STDAPI_(BOOL) SetFolderString(BOOL fCreate, LPCTSTR pszFolder, LPCTSTR pszProvider, LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszData);
  149. STDAPI_(BOOL) GetFolderString(LPCTSTR pszFolder, LPCTSTR pszProvider, LPTSTR pszOut, int cch, LPCTSTR pszKey);
  150. STDAPI SHMultiFileProperties(IDataObject *pdtobj, DWORD dwFlags);
  151. STDAPI CFSFolder_CreateLinks(HWND hwnd, IShellFolder *psf, IDataObject *pdtobj, LPCTSTR pszDir, DWORD fMask);
  152. STDAPI CFSFolder_IconEvent(LONG lEvent, LPCITEMIDLIST pidl, LPCITEMIDLIST pidlExtra);
  153. STDAPI_(void) CFSFolder_UpdateIcon(IShellFolder *psf, LPCITEMIDLIST pidl);
  154. class CFSFolder : public CAggregatedUnknown,
  155. public IShellFolder2,
  156. public IShellIcon,
  157. public IShellIconOverlay,
  158. public IPersistFolder3,
  159. public IStorage,
  160. public ITransferDest,
  161. public IPropertySetStorage,
  162. public IItemNameLimits,
  163. public IContextMenuCB,
  164. public ISetFolderEnumRestriction,
  165. public IOleCommandTarget
  166. {
  167. friend CFSFolderViewCB;
  168. friend CFSDropTarget;
  169. friend CFileSysEnum;
  170. friend CFSFolderEnumSTATSTG;
  171. friend CFSFolderPropertyBag;
  172. friend CFileSysItem;
  173. friend CFileSysItemString;
  174. friend CFSAssocEnumData;
  175. // these are evil, get rid of as many of these as possible
  176. friend HRESULT SHMultiFileProperties(IDataObject *pdtobj, DWORD dwFlags);
  177. friend HRESULT CFSFolder_CreateLinks(HWND hwnd, IShellFolder *psf, IDataObject *pdtobj, LPCTSTR pszDir, DWORD fMask);
  178. friend HRESULT CFSFolder_IconEvent(LONG lEvent, LPCITEMIDLIST pidl, LPCITEMIDLIST pidlExtra);
  179. friend void CFSFolder_UpdateIcon(IShellFolder *psf, LPCITEMIDLIST pidl);
  180. friend HRESULT CFSFolder_CompareNames(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  181. friend DWORD CFSFolder_PropertiesThread(void *pv);
  182. friend HRESULT CFSFolder_CreateFolder(IUnknown *punkOuter, LPBC pbc, LPCITEMIDLIST pidl,
  183. const PERSIST_FOLDER_TARGET_INFO *pf, REFIID riid, void **ppv);
  184. friend LPCIDFOLDER CFSFolder_IsValidID(LPCITEMIDLIST pidl);
  185. friend BOOL CFSFolder_IsCommonItem(LPCITEMIDLIST pidl);
  186. public:
  187. // IUnknown
  188. STDMETHODIMP QueryInterface(REFIID riid, void **ppv) { return CAggregatedUnknown::QueryInterface(riid, ppv); };
  189. STDMETHODIMP_(ULONG) AddRef(void) { return CAggregatedUnknown::AddRef(); };
  190. STDMETHODIMP_(ULONG) Release(void) { return CAggregatedUnknown::Release(); };
  191. // IShellFolder
  192. STDMETHODIMP ParseDisplayName(HWND hwnd, LPBC pbc, LPOLESTR pszName, ULONG *pchEaten, LPITEMIDLIST *ppidl, ULONG *pdwAttributes);
  193. STDMETHODIMP EnumObjects(HWND hwnd, DWORD grfFlags, IEnumIDList **ppenumIDList);
  194. STDMETHODIMP BindToObject(LPCITEMIDLIST pidl, LPBC pbc, REFIID riid, void **ppv);
  195. STDMETHODIMP BindToStorage(LPCITEMIDLIST pidl, LPBC pbc, REFIID riid, void **ppv);
  196. STDMETHODIMP CompareIDs(LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  197. STDMETHODIMP CreateViewObject (HWND hwndOwner, REFIID riid, void **ppv);
  198. STDMETHODIMP GetAttributesOf(UINT cidl, LPCITEMIDLIST * apidl, ULONG *rgfInOut);
  199. STDMETHODIMP GetUIObjectOf(HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, void **ppv);
  200. STDMETHODIMP GetDisplayNameOf(LPCITEMIDLIST pidl, DWORD uFlags, STRRET *pName);
  201. STDMETHODIMP SetNameOf(HWND hwnd, LPCITEMIDLIST pidl, LPCOLESTR pszName, DWORD uFlags, LPITEMIDLIST * ppidlOut);
  202. // IShellFolder2
  203. STDMETHODIMP GetDefaultSearchGUID(GUID *pGuid);
  204. STDMETHODIMP EnumSearches(IEnumExtraSearch **ppenum);
  205. STDMETHODIMP GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG *pDisplay);
  206. STDMETHODIMP GetDefaultColumnState(UINT iColumn, DWORD *pbState);
  207. STDMETHODIMP GetDetailsEx(LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, VARIANT *pv);
  208. STDMETHODIMP GetDetailsOf(LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS *pDetails);
  209. STDMETHODIMP MapColumnToSCID(UINT iColumn, SHCOLUMNID *pscid);
  210. // IPersist
  211. STDMETHODIMP GetClassID(LPCLSID lpClassID);
  212. // IPersistFolder
  213. STDMETHODIMP Initialize(LPCITEMIDLIST pidl);
  214. // IPersistFolder2
  215. STDMETHODIMP GetCurFolder(LPITEMIDLIST *ppidl);
  216. // IPersistFolder3
  217. STDMETHODIMP InitializeEx(IBindCtx *pbc, LPCITEMIDLIST pidlRoot, const PERSIST_FOLDER_TARGET_INFO *pfti);
  218. STDMETHODIMP GetFolderTargetInfo(PERSIST_FOLDER_TARGET_INFO *pfti);
  219. // IShellIcon methods
  220. STDMETHODIMP GetIconOf(LPCITEMIDLIST pidl, UINT flags, int *piIndex);
  221. // IShellIconOverlay methods
  222. STDMETHODIMP GetOverlayIndex(LPCITEMIDLIST pidl, int * pIndex);
  223. STDMETHODIMP GetOverlayIconIndex(LPCITEMIDLIST pidl, int * pIndex);
  224. // IStorage
  225. STDMETHODIMP CreateStream(LPCWSTR pszRel, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream **ppstm);
  226. STDMETHODIMP OpenStream(LPCWSTR pszRel, VOID *reserved1, DWORD grfMode, DWORD reserved2, IStream **ppstm);
  227. STDMETHODIMP CreateStorage(LPCWSTR pszRel, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStorage **ppstg);
  228. STDMETHODIMP OpenStorage(LPCWSTR pszRel, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstg);;
  229. STDMETHODIMP CopyTo(DWORD ciidExclude, const IID *rgiidExclude, SNB snbExclude, IStorage *pstgDest);
  230. STDMETHODIMP MoveElementTo(LPCWSTR pszRel, IStorage *pstgDest, LPCWSTR pwcsNewName, DWORD grfFlags);
  231. STDMETHODIMP Commit(DWORD grfCommitFlags);
  232. STDMETHODIMP Revert();
  233. STDMETHODIMP EnumElements(DWORD reserved1, void *reserved2, DWORD reserved3, IEnumSTATSTG **ppenum);
  234. STDMETHODIMP DestroyElement(LPCWSTR pszRel);
  235. STDMETHODIMP RenameElement(LPCWSTR pwcsOldName, LPCWSTR pwcsNewName);
  236. STDMETHODIMP SetElementTimes(LPCWSTR pszRel, const FILETIME *pctime, const FILETIME *patime, const FILETIME *pmtime);
  237. STDMETHODIMP SetClass(REFCLSID clsid);
  238. STDMETHODIMP SetStateBits(DWORD grfStateBits, DWORD grfMask);
  239. STDMETHODIMP Stat(STATSTG *pstatstg, DWORD grfStatFlag);
  240. // ITransferDest
  241. STDMETHODIMP Advise(ITransferAdviseSink *pAdvise, DWORD *pdwCookie);
  242. STDMETHODIMP Unadvise(DWORD dwCookie);
  243. STDMETHODIMP OpenElement(const WCHAR *pwcsName, STGXMODE grfMode, DWORD *pdwType, REFIID riid, void **ppunk);
  244. STDMETHODIMP CreateElement(const WCHAR *pwcsName, IShellItem *psiTemplate, STGXMODE grfMode, DWORD dwType, REFIID riid, void **ppunk);
  245. STDMETHODIMP MoveElement(IShellItem *psiItem, WCHAR *pwcsNewName, STGXMOVE grfOptions);
  246. STDMETHODIMP DestroyElement(const WCHAR *pwcsName, STGXDESTROY grfOptions);
  247. // IPropertySetStorage methods
  248. STDMETHODIMP Create(REFFMTID fmtid, const CLSID * pclsid, DWORD grfFlags, DWORD grfMode, IPropertyStorage** ppPropStg);
  249. STDMETHODIMP Open(REFFMTID fmtid, DWORD grfMode, IPropertyStorage** ppPropStg);
  250. STDMETHODIMP Delete(REFFMTID fmtid);
  251. STDMETHODIMP Enum(IEnumSTATPROPSETSTG** ppenum);
  252. // IContextMenuCB
  253. STDMETHODIMP CallBack(IShellFolder *psf, HWND hwnd, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam);
  254. // IItemNameLimits
  255. STDMETHODIMP GetValidCharacters(LPWSTR *ppwszValidChars, LPWSTR *ppwszInvalidChars);
  256. STDMETHODIMP GetMaxLength(LPCWSTR pszName, int *piMaxNameLen);
  257. // ISetFolderEnumRestriction
  258. STDMETHODIMP SetEnumRestriction(DWORD dwRequired, DWORD dwForbidden);
  259. // IOleCommandTarget
  260. STDMETHODIMP QueryStatus(const GUID *pguidCmdGroup,
  261. ULONG cCmds, OLECMD rgCmds[], OLECMDTEXT *pcmdtext);
  262. STDMETHODIMP Exec(const GUID *pguidCmdGroup,
  263. DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
  264. CFSFolder(IUnknown *punkOuter);
  265. protected:
  266. LPCITEMIDLIST _GetIDList() { return _pidl; };
  267. HRESULT v_InternalQueryInterface(REFIID riid, void **ppv);
  268. virtual ~CFSFolder();
  269. HRESULT _GetPathForItems(LPCIDFOLDER pidfParent, LPCIDFOLDER pidf, LPTSTR pszPath);
  270. HRESULT _GetPathForItem(LPCIDFOLDER pidf, LPWSTR pszPath);
  271. HRESULT _GetPath(LPTSTR pszPath);
  272. static HRESULT _GetAltDisplayName(LPCIDFOLDER pidf, LPTSTR pszName, DWORD cchName);
  273. static HRESULT _MakePossessiveName(LPCTSTR pszFile, LPCTSTR pszOwner, LPTSTR pszBuffer, INT cchBuffer);
  274. HRESULT _GetUsersDisplayName(LPCTSTR pszOwner, LPTSTR pszBuffer, INT cchBuffer);
  275. HRESULT _SetLocalizedDisplayName(LPCIDFOLDER pidf, LPCTSTR pszName);
  276. void _UpdateItem(LPCIDFOLDER pidf);
  277. DWORD _Attributes();
  278. UINT _GetCSIDL();
  279. BOOL _IsCSIDL(UINT csidl);
  280. UINT _GetItemExStrings(LPCIDFOLDER pidfSimpleParent, const WIN32_FIND_DATA *pfd, EXSTRINGS *pxs);
  281. HRESULT _CreateIDList(const WIN32_FIND_DATA *pfd, LPCIDFOLDER pidfSimpleParent, LPITEMIDLIST *ppidl);
  282. HRESULT _Properties(LPCITEMIDLIST pidlParent, IDataObject *pdtobj, LPCTSTR pStartPage);
  283. HRESULT _Reset();
  284. HRESULT _CreateInstance(HWND hwnd, IDropTarget** ppdt);
  285. HRESULT _CreateEnum(IUnknown *punk, HWND hwnd, DWORD grfFlags, IEnumIDList **ppenum);
  286. HRESULT _GetJunctionForBind(LPCIDFOLDER pidf, LPIDFOLDER *ppidfBind, LPCITEMIDLIST *ppidlRight);
  287. LPCTSTR _BindHandlerName(REFIID riid);
  288. HRESULT _Bind(LPBC pbc, LPCIDFOLDER pidf, REFIID riid, void **ppv);
  289. HRESULT _LoadHandler(LPCIDFOLDER pidf, DWORD grfMode, LPCTSTR pszHandlerType, REFIID riid, void **ppv);
  290. HRESULT _HandlerCreateInstance(LPCIDFOLDER pidf, PCWSTR pszClsid, DWORD grfMode, REFIID riid, void **ppv);
  291. HRESULT _CreateShimgvwExtractor(LPCIDFOLDER pidf, REFIID riid, void **ppv);
  292. BOOL _IsSlowPath();
  293. HRESULT _GetToolTipForItem(LPCIDFOLDER pidf, REFIID riid, void **ppv);
  294. HRESULT _GetIntroText(LPCIDFOLDER pidf, WCHAR* pwszIntroText, UINT cchIntroText);
  295. // GetDetailsEx() helpers.
  296. HRESULT _GetAttributesDescription(LPCIDFOLDER pidf, VARIANT *pv);
  297. HRESULT _GetAttributesDescriptionBuilder(LPWSTR szAttributes, size_t cchAttributes, LPWSTR szAttribute);
  298. HRESULT _GetLinkTarget(LPCITEMIDLIST pidl, VARIANT *pv);
  299. HRESULT _GetNetworkLocation(LPCIDFOLDER pidf, VARIANT *pv);
  300. HRESULT _GetComputerName(LPCIDFOLDER pidf, VARIANT *pv);
  301. HRESULT _GetComputerName_FromPath(LPCWSTR pszPath, VARIANT *pv);
  302. HRESULT _GetComputerName_FromUNC(LPWSTR pszPath, VARIANT *pv);
  303. HRESULT _GetCSCStatus(LPCIDFOLDER pidf, VARIANT *pv);
  304. BOOL _GetFolderFlags(LPCIDFOLDER pidf, UINT *prgfFlags);
  305. BOOL _GetFolderIconPath(LPCIDFOLDER pidf, LPTSTR pszIcon, int cchMax, UINT *pIndex);
  306. static DWORD CALLBACK _PropertiesThread(void *pv);
  307. static DWORD _GetClassFlags(LPCIDFOLDER pidf);
  308. static BOOL _GetClass(LPCIDFOLDER pidf, LPTSTR pszClass, UINT cch);
  309. UINT _GetContextMenuKeys(LPCIDFOLDER pidf, HKEY *aKeys, UINT cKeys, IAssociationArray **ppaa);
  310. BOOL _CheckDefaultIni(LPCIDFOLDER pidfLast, LPTSTR pszIniPath);
  311. HRESULT _CompareExtendedProp(int iColumn, LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  312. static HRESULT _CompareModifiedDate(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  313. static HRESULT _CompareCreateTime(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  314. static HRESULT _CompareAccessTime(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  315. static HRESULT _CompareAttribs(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  316. static HRESULT _CompareFileTypes(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  317. HRESULT _CompareNames(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2, BOOL fCaseSensitive, BOOL fCanonical);
  318. static HRESULT _CompareFolderness(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  319. BOOL _DefaultShowExt();
  320. BOOL _ShowExtension(LPCIDFOLDER pidf);
  321. static HRESULT _GetClassKey(LPCIDFOLDER pidf, HKEY *phkeyProgID);
  322. // file system, non junction point folder
  323. static BOOL _IsJunction(LPCIDFOLDER pidf);
  324. static BYTE _GetType(LPCIDFOLDER pidf);
  325. static BOOL _IsSimpleID(LPCIDFOLDER pidf);
  326. static LPIDFOLDER _FindLastID(LPCIDFOLDER pidf);
  327. static LPIDFOLDER _Next(LPCIDFOLDER pidf);
  328. static LPCIDFOLDER _IsValidID(LPCITEMIDLIST pidl);
  329. static LPCIDFOLDER _IsValidIDHack(LPCITEMIDLIST pidl);
  330. static BOOL _IsCommonItem(LPCITEMIDLIST pidl);
  331. static BOOL _IsFile(LPCIDFOLDER pidf);
  332. static BOOL _IsFolder(LPCIDFOLDER pidf);
  333. static BOOL _IsFileFolder(LPCIDFOLDER pidf);
  334. static BOOL _IsSystemFolder(LPCIDFOLDER pidf);
  335. static BOOL _IsReal(LPCIDFOLDER pidf);
  336. BOOL _IsSelfSystemFolder();
  337. BOOL _HasLocalizedFileNames();
  338. BOOL _IsOfflineCSC(LPCIDFOLDER pidf);
  339. BOOL _IsOfflineCSC(LPCTSTR pszPath);
  340. HRESULT _InitFolder(IBindCtx *pbc, LPCIDFOLDER pidf, IUnknown **ppunk);
  341. HRESULT _InitStgFolder(LPCIDFOLDER pidf, LPCWSTR wszPath, DWORD grfMode, REFIID riid, void **ppv);
  342. BOOL _GetMountingPointInfo(LPCIDFOLDER pidf, LPTSTR pszMountPoint, DWORD cchMountPoint);
  343. HRESULT _CreateContextMenu(HWND hwnd, LPCIDFOLDER pidf, LPCITEMIDLIST *apidl, UINT cidl, IContextMenu **ppcm);
  344. HRESULT _AssocCreate(LPCIDFOLDER pidf, REFIID riid, void **ppv);
  345. static BOOL _GetJunctionClsid(LPCIDFOLDER pidf, CLSID *pclsidRet);
  346. static LPCTSTR _GetTypeName(LPCIDFOLDER pidf);
  347. static HRESULT _GetTypeNameBuf(LPCIDFOLDER pidf, LPTSTR pszName, int cchNameMax);
  348. static LPWSTR _CopyName(LPCIDFOLDER pidf, LPWSTR pszName, UINT cchName);
  349. static int _CopyUIName(LPCIDFOLDER pidf, LPTSTR pszName, UINT cchName);
  350. static HRESULT _AppendItemToPath(LPTSTR pszPath, LPCIDFOLDER pidf);
  351. static LPTSTR _CopyAltName(LPCIDFOLDER pidf, LPTSTR pszName, UINT cchName);
  352. static void _GetSize(LPCITEMIDLIST pidlParent, LPCIDFOLDER pidf, ULONGLONG *pcbSize);
  353. static LPCSTR _GetAltName(LPCIDFOLDER pidf);
  354. static HRESULT _FindDataFromIDFolder(LPCIDFOLDER pidf, WIN32_FIND_DATAW *pfd, BOOL fAllowSimplePid);
  355. static DWORD _GetUID(LPCIDFOLDER pidf);
  356. static LPCIDFOLDER _FindJunction(LPCIDFOLDER pidf);
  357. static LPCITEMIDLIST _FindJunctionNext(LPCIDFOLDER pidf);
  358. ULONGLONG _Size(LPCIDFOLDER pidf);
  359. HRESULT _NormalGetDisplayNameOf(LPCIDFOLDER pidf, STRRET *pStrRet);
  360. HRESULT _NormalDisplayName(LPCIDFOLDER pidf, LPWSTR psz, UINT cch);
  361. BOOL _GetBindCLSID(IBindCtx *pbc, LPCIDFOLDER pidf, CLSID *pclsid);
  362. HRESULT _InitColData(LPCIDFOLDER pidf, SHCOLUMNDATA* pscd);
  363. LPIDFOLDER _MarkAsJunction(LPCIDFOLDER pidfSimpleParent, LPIDFOLDER pidf, LPCTSTR pszName);
  364. HRESULT _CreateIDListFromName(LPCTSTR pszName, DWORD dwAttribs, IBindCtx *pbc, LPITEMIDLIST *ppidl);
  365. BOOL _CanSeeInThere(LPCTSTR pszName);
  366. HRESULT _ParseSimple(LPCWSTR pszPath, const WIN32_FIND_DATA *pfdLast, LPITEMIDLIST *ppidl);
  367. HRESULT _FindDataFromName(LPCTSTR pszName, DWORD dwAttribs, IBindCtx *pbc, WIN32_FIND_DATA **ppfd);
  368. HRESULT _CheckDriveRestriction(HWND hwnd, REFIID riid);
  369. HRESULT _CreateUIHandler(REFIID riid, void **ppv);
  370. BOOL _IsNetPath();
  371. int _GetDefaultFolderIcon();
  372. HRESULT _CreateDefExtIcon(LPCIDFOLDER pidf, REFIID riid, void **ppv);
  373. BOOL _FindColHandler(UINT iCol, UINT iN, COLUMNLISTENTRY *pcle);
  374. BOOL _ShouldNotShowColumn(UINT iColumn);
  375. BOOL _ShouldShowExtendedColumn(const SHCOLUMNID* pscid);
  376. HRESULT _MapSCIDToColumn(const SHCOLUMNID* pscid, UINT* puCol);
  377. HRESULT _ExtendedColumn(LPCIDFOLDER pidf, UINT iColumn, SHELLDETAILS *pDetails);
  378. HRESULT _LoadColumnHandlers();
  379. HRESULT _GetOverlayInfo(LPCITEMIDLIST pidl, int * pIndex, DWORD dwFlags);
  380. void _DestroyColHandlers();
  381. HRESULT _GetFullPath(LPCWSTR pszRelPath, LPWSTR pszFull);
  382. HRESULT _Delete(LPCWSTR pszFile);
  383. HRESULT _OpenCreateStorage(LPCWSTR pwcsName, DWORD grfMode, IStorage **ppstg, BOOL fCreate);
  384. HRESULT _OpenCreateStream(LPCWSTR pwcsName, DWORD grfMode, IStream **ppstm, BOOL fCreate);
  385. HRESULT _SetStgMode(DWORD grfMode);
  386. HRESULT _LoadPropHandler();
  387. HRESULT _GetStatStgFromItemName(LPCTSTR szName, STATSTG * pstat);
  388. HRESULT _CreateFolderPropertyBag(DWORD grfMode, LPCIDFOLDER pidfLast, REFIID riid, void **ppv);
  389. HRESULT _GetPropertyUI();
  390. LPITEMIDLIST _pidl; // Absolute IDList (location in the name space)
  391. LPITEMIDLIST _pidlTarget; // Absolute IDList for folder target (location in namespace to enumerate)
  392. // WARNING: _csidlTrack overrides _pidlTarget
  393. LPTSTR _pszPath; // file system path (may be different from _pidl)
  394. LPTSTR _pszNetProvider; // network provider (for net calls we may need to make)
  395. CLSID _clsidBind; // use CLSID_NULL for normal case
  396. int _cHiddenFiles; // view callback and enumerator share these
  397. ULONGLONG _cbSize;
  398. UINT _csidl; // CSIDL_ value of this folder (if known)
  399. DWORD _dwAttributes; // attributes of this folder (if known)
  400. int _csidlTrack; // CSIDL_ that we follow dynamically
  401. BOOL _fCachedCLSID : 1; // clsidView is already cached
  402. BOOL _fHasCLSID : 1; // clsidView has a valid CLSID
  403. CLSID _clsidView; // CLSID for View object
  404. HDSA _hdsaColHandlers; // cached list of columns and handlers
  405. DWORD _dwColCount; // count of unique columns
  406. int _iFolderIcon; // icon for sub folders to inherit
  407. BOOL _bUpdateExtendedCols; // set to TRUE in response to SFVM_INSERTITEM callback, passed to IColumnProvider::GetItemData then cleared
  408. BOOL _bSlowPath; // Lazy-calculated value of whether the folder is on a slow path
  409. BOOL _fDontForceCreate; // don't succeed with STGM_CREATE passed to ParseDisplayName for a non-existent item
  410. FVCBFOLDERTYPE _nFolderType;
  411. TRIBIT _tbHasLocalizedFileNamesSection; // Lazy-calculated value of whether the folder has a desktop.ini with a LocalizedFileNames section
  412. TRIBIT _tbDefShowExt; // cache of SHGetSetSettings(SSF_SHOWEXTENSIONS)
  413. TRIBIT _tbOfflineCSC; // cache of _IsOfflineCSC(_pidl)
  414. DWORD _grfFlags;
  415. DWORD _dwEnumRequired; // SetEnumRestriction
  416. DWORD _dwEnumForbidden; // SetEnumRestriction
  417. IPropertySetStorage *_pstg;
  418. IPropertyUI *_pPropertyUI;
  419. ITransferAdviseSink * _pAdvise;
  420. };
  421. // fstree.cpp
  422. STDAPI CFSFolderCallback_Create(CFSFolder *pFSFolder, IShellFolderViewCB **ppsfvcb);
  423. STDAPI CFSDropTarget_CreateInstance(CFSFolder* pFSFolder, HWND hwnd, IDropTarget** ppdt);
  424. STDAPI CFSFolder_CreateEnum(CFSFolder *pfsf, HWND hwnd, DWORD grfFlags, IEnumIDList **ppenum);
  425. STDAPI CFolderExtractImage_Create(IShellFolder *psf, LPCITEMIDLIST pidl, REFIID riid, void **ppvObj);
  426. class CFSIconManager : public ICustomIconManager
  427. {
  428. public:
  429. // IUnknown
  430. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  431. STDMETHODIMP_(ULONG) AddRef(void);
  432. STDMETHODIMP_(ULONG) Release(void);
  433. // ICustomIconManager
  434. STDMETHODIMP SetIcon(LPCWSTR pszIconPath,int iIcon);
  435. STDMETHODIMP SetDefaultIcon();
  436. STDMETHODIMP GetDefaultIconHandle(HICON *phIcon);
  437. STDMETHODIMP GetIcon(LPWSTR pszIconPath, int cchszIconPath, int *piIconIndex) = 0;
  438. protected:
  439. HRESULT _Init(LPCITEMIDLIST pidl, IShellFolder *psf);
  440. WCHAR _wszPath[MAX_PATH];
  441. CFSIconManager();
  442. virtual STDMETHODIMP _SetIconEx(LPCWSTR pszIconPath,int iIconIndex, BOOL fChangeNotify) = 0;
  443. virtual STDMETHODIMP _SetDefaultIconEx(BOOL fChangeNotify) = 0;
  444. private:
  445. long _cRef;
  446. };
  447. class CFileFolderIconManager : public CFSIconManager
  448. {
  449. public:
  450. friend HRESULT CFileFolderIconManager_Create(IShellFolder *psf, LPCITEMIDLIST pidl, REFIID riid, void **ppv);
  451. // ICustomIconManager
  452. STDMETHODIMP GetIcon(LPWSTR pszIconPath, int cchszIconPath, int *piIconIndex);
  453. protected:
  454. STDMETHODIMP _SetIconEx(LPCWSTR pszIconPath,int iIconIndex, BOOL fChangeNotify);
  455. STDMETHODIMP _SetDefaultIconEx(BOOL fChangeNotify);
  456. };