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.

210 lines
5.7 KiB

  1. //*******************************************************************************************
  2. //
  3. // Filename : Folder.h
  4. //
  5. // Definitions of CCabFolder and CCabItemList
  6. //
  7. // Copyright (c) 1994 - 1997 Microsoft Corporation. All rights reserved
  8. //
  9. //*******************************************************************************************
  10. #ifndef _CABFOLD_H_
  11. #define _CABFOLD_H_
  12. enum _CV_COLS
  13. {
  14. CV_COL_NAME = 0,
  15. CV_COL_SIZE,
  16. CV_COL_TYPE,
  17. CV_COL_MODIFIED,
  18. CV_COL_PATH,
  19. CV_COL_MAX,
  20. } ;
  21. #define IsEqualSCID(a, b) (((a).pid == (b).pid) && IsEqualIID((a).fmtid, (b).fmtid) )
  22. #define DEFINE_SCID(name, fmtid, pid) const SHCOLUMNID name = { fmtid, pid }
  23. typedef struct _CABITEM
  24. {
  25. WORD wSize;
  26. DWORD dwFileSize;
  27. USHORT uFileDate;
  28. USHORT uFileTime;
  29. USHORT uFileAttribs;
  30. USHORT cPathChars;
  31. WCHAR szName[1];
  32. } CABITEM;
  33. typedef UNALIGNED CABITEM *LPCABITEM;
  34. class CCabItemList
  35. {
  36. public:
  37. CCabItemList(UINT uStep) {m_uStep=uStep;}
  38. CCabItemList() {CCabItemList(8);}
  39. ~CCabItemList() {CleanList();}
  40. enum
  41. {
  42. State_UnInit,
  43. State_Init,
  44. State_OutOfMem,
  45. };
  46. UINT GetState();
  47. LPCABITEM operator[](UINT nIndex)
  48. {
  49. return((LPCABITEM)DPA_GetPtr(m_dpaList, nIndex));
  50. }
  51. UINT GetCount() {return(GetState()==State_Init ? DPA_GetPtrCount(m_dpaList) : 0);}
  52. LPCABITEM* GetArray() {return(GetState()==State_Init ? (LPCABITEM*) DPA_GetPtrPtr(m_dpaList) : NULL);}
  53. BOOL InitList();
  54. BOOL AddItems(LPCABITEM *apit, UINT cpit);
  55. BOOL AddItem(LPCTSTR pszName, DWORD dwFileSize,
  56. UINT uFileDate, UINT uFileTime, UINT uFileAttribs);
  57. int FindInList(LPCTSTR pszName, DWORD dwFileSize,
  58. UINT uFileDate, UINT uFileTime, UINT uFileAttribs);
  59. BOOL IsInList(LPCTSTR pszName, DWORD dwFileSize,
  60. UINT uFileDate, UINT uFileTime, UINT uFileAttribs)
  61. {
  62. return(FindInList(pszName, dwFileSize, uFileDate, uFileTime, uFileAttribs) >= 0);
  63. }
  64. private:
  65. BOOL StoreItem(LPITEMIDLIST pidl);
  66. void CleanList();
  67. private:
  68. UINT m_uStep;
  69. HDPA m_dpaList;
  70. } ;
  71. class CCabFolder : public IPersistFolder2, public IShellFolder2, public IShellFolderViewCB
  72. {
  73. public:
  74. CCabFolder() : m_pidlHere(0), m_lItems(1024/sizeof(void *)) {}
  75. ~CCabFolder()
  76. {
  77. if (m_pidlHere)
  78. {
  79. ILFree(m_pidlHere);
  80. }
  81. }
  82. // *** IUnknown methods ***
  83. STDMETHODIMP QueryInterface(
  84. REFIID riid,
  85. void ** ppvObj);
  86. STDMETHODIMP_(ULONG) AddRef(void);
  87. STDMETHODIMP_(ULONG) Release(void);
  88. // *** IParseDisplayName method ***
  89. STDMETHODIMP ParseDisplayName(
  90. HWND hwndOwner,
  91. LPBC pbc,
  92. LPOLESTR lpszDisplayName,
  93. ULONG * pchEaten,
  94. LPITEMIDLIST * ppidl,
  95. ULONG *pdwAttributes);
  96. // *** IOleContainer methods ***
  97. STDMETHODIMP EnumObjects(
  98. HWND hwndOwner,
  99. DWORD grfFlags,
  100. LPENUMIDLIST * ppenumIDList);
  101. // *** IShellFolder methods ***
  102. STDMETHODIMP BindToObject(
  103. LPCITEMIDLIST pidl,
  104. LPBC pbc,
  105. REFIID riid,
  106. void ** ppvObj);
  107. STDMETHODIMP BindToStorage(
  108. LPCITEMIDLIST pidl,
  109. LPBC pbc,
  110. REFIID riid,
  111. void ** ppvObj);
  112. STDMETHODIMP CompareIDs(
  113. LPARAM lParam,
  114. LPCITEMIDLIST pidl1,
  115. LPCITEMIDLIST pidl2);
  116. STDMETHODIMP CreateViewObject(
  117. HWND hwndOwner,
  118. REFIID riid,
  119. void ** ppvObj);
  120. STDMETHODIMP GetAttributesOf(
  121. UINT cidl,
  122. LPCITEMIDLIST * apidl,
  123. ULONG * rgfInOut);
  124. STDMETHODIMP GetUIObjectOf(
  125. HWND hwndOwner,
  126. UINT cidl,
  127. LPCITEMIDLIST * apidl,
  128. REFIID riid,
  129. UINT * prgfInOut,
  130. void ** ppvObj);
  131. STDMETHODIMP GetDisplayNameOf(
  132. LPCITEMIDLIST pidl,
  133. DWORD dwReserved,
  134. LPSTRRET lpName);
  135. STDMETHODIMP SetNameOf(
  136. HWND hwndOwner,
  137. LPCITEMIDLIST pidl,
  138. LPCOLESTR lpszName,
  139. DWORD dwReserved,
  140. LPITEMIDLIST * ppidlOut);
  141. // IShellFolder2
  142. STDMETHODIMP GetDefaultSearchGUID(GUID *pguid) { return E_NOTIMPL; };
  143. STDMETHODIMP EnumSearches(IEnumExtraSearch **ppenum) { return E_NOTIMPL; };
  144. STDMETHODIMP GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG *pDisplay) { return E_NOTIMPL; };
  145. STDMETHODIMP GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags) { return E_NOTIMPL; };
  146. STDMETHODIMP GetDetailsEx(LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, VARIANT *pv);
  147. STDMETHODIMP GetDetailsOf(LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS *psd);
  148. STDMETHODIMP MapColumnToSCID(UINT iCol, SHCOLUMNID *pscid);
  149. // IPersist
  150. STDMETHODIMP GetClassID(CLSID *pClassID);
  151. // IPersistFolder
  152. STDMETHODIMP Initialize(LPCITEMIDLIST pidl);
  153. // IPersistFolder2
  154. STDMETHODIMP GetCurFolder(LPITEMIDLIST *ppidl);
  155. // IShellFolderViewCB
  156. STDMETHODIMP MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam);
  157. public:
  158. static LPITEMIDLIST CreateIDList(LPCTSTR pszName, DWORD dwFileSize,
  159. UINT uFileDate, UINT uFileTime, UINT uFileAttribs);
  160. static void GetNameOf(LPCABITEM pit, LPSTRRET lpName);
  161. static void GetPathOf(LPCABITEM pit, LPSTRRET lpName);
  162. static void GetTypeOf(LPCABITEM pit, LPSTRRET lpName);
  163. BOOL GetPath(LPTSTR szPath);
  164. private:
  165. static void CALLBACK EnumToList(LPCTSTR pszFile, DWORD dwSize, UINT date,
  166. UINT time, UINT attribs, LPARAM lParam);
  167. HRESULT InitItems();
  168. private:
  169. CRefDll m_cRefDll;
  170. CRefCount m_cRef;
  171. LPITEMIDLIST m_pidlHere; // maintains the current pidl
  172. CCabItemList m_lItems;
  173. friend class CEnumCabObjs;
  174. } ;
  175. #endif // _CABFOLD_H_