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.

452 lines
13 KiB

  1. /*****************************************************************************\
  2. * *
  3. * storage.h - Definitions for the strutured storage system
  4. * *
  5. * OLE Version 2.0 *
  6. * *
  7. * Copyright (c) 1992-1993, Microsoft Corp. All rights reserved. *
  8. * *
  9. \*****************************************************************************/
  10. #if !defined( _STORAGE_H_ )
  11. #define _STORAGE_H_
  12. #include <compobj.h>
  13. /****** Storage Error Codes *************************************************/
  14. /* DOS-based error codes */
  15. #define STG_E_INVALIDFUNCTION \
  16. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x01)
  17. #define STG_E_FILENOTFOUND \
  18. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x02)
  19. #define STG_E_PATHNOTFOUND \
  20. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x03)
  21. #define STG_E_TOOMANYOPENFILES \
  22. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x04)
  23. #define STG_E_ACCESSDENIED \
  24. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x05)
  25. #define STG_E_INVALIDHANDLE \
  26. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x06)
  27. #define STG_E_INSUFFICIENTMEMORY \
  28. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x08)
  29. #define STG_E_INVALIDPOINTER \
  30. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x09)
  31. #define STG_E_NOMOREFILES \
  32. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x12)
  33. #define STG_E_DISKISWRITEPROTECTED \
  34. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x13)
  35. #define STG_E_SEEKERROR \
  36. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x19)
  37. #define STG_E_WRITEFAULT \
  38. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x1d)
  39. #define STG_E_READFAULT \
  40. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x1e)
  41. #define STG_E_SHAREVIOLATION \
  42. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x20)
  43. #define STG_E_LOCKVIOLATION \
  44. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x21)
  45. #define STG_E_FILEALREADYEXISTS \
  46. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x50)
  47. #define STG_E_INVALIDPARAMETER \
  48. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x57)
  49. #define STG_E_MEDIUMFULL \
  50. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x70)
  51. #define STG_E_ABNORMALAPIEXIT \
  52. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0xfa)
  53. #define STG_E_INVALIDHEADER \
  54. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0xfb)
  55. #define STG_E_INVALIDNAME \
  56. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0xfc)
  57. #define STG_E_UNKNOWN \
  58. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0xfd)
  59. #define STG_E_UNIMPLEMENTEDFUNCTION\
  60. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0xfe)
  61. #define STG_E_INVALIDFLAG \
  62. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0xff)
  63. /* Standard storage error codes */
  64. #define STG_E_INUSE \
  65. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x100)
  66. #define STG_E_NOTCURRENT \
  67. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x101)
  68. #define STG_E_REVERTED \
  69. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x102)
  70. #define STG_E_CANTSAVE \
  71. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x103)
  72. #define STG_E_OLDFORMAT \
  73. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x104)
  74. #define STG_E_OLDDLL \
  75. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x105)
  76. #define STG_E_SHAREREQUIRED \
  77. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x106)
  78. #define STG_E_NOTFILEBASEDSTORAGE \
  79. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x107)
  80. #define STG_E_EXTANTMARSHALLINGS \
  81. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x108)
  82. /* Information returns */
  83. #define STG_S_CONVERTED \
  84. MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_STORAGE, 0x200)
  85. /****** Storage types *******************************************************/
  86. #if defined(_M_I286)
  87. typedef char TCHAR;
  88. #ifndef HUGEP
  89. #define HUGEP _huge
  90. #endif
  91. #else
  92. typedef char TCHAR;
  93. #ifndef HUGEP
  94. #define HUGEP
  95. #endif
  96. #endif
  97. #define CWCSTORAGENAME 32
  98. /* Storage instantiation modes */
  99. #define STGM_DIRECT 0x00000000L
  100. #define STGM_TRANSACTED 0x00010000L
  101. #define STGM_READ 0x00000000L
  102. #define STGM_WRITE 0x00000001L
  103. #define STGM_READWRITE 0x00000002L
  104. #define STGM_SHARE_DENY_NONE 0x00000040L
  105. #define STGM_SHARE_DENY_READ 0x00000030L
  106. #define STGM_SHARE_DENY_WRITE 0x00000020L
  107. #define STGM_SHARE_EXCLUSIVE 0x00000010L
  108. #define STGM_PRIORITY 0x00040000L
  109. #define STGM_DELETEONRELEASE 0x04000000L
  110. #define STGM_CREATE 0x00001000L
  111. #define STGM_CONVERT 0x00020000L
  112. #define STGM_FAILIFTHERE 0x00000000L
  113. /* Storage commit types */
  114. typedef enum tagSTGC
  115. {
  116. STGC_DEFAULT = 0,
  117. STGC_OVERWRITE = 1,
  118. STGC_ONLYIFCURRENT = 2,
  119. STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 4
  120. } STGC;
  121. /* Stream name block definitions */
  122. typedef char FAR * FAR *SNB;
  123. #ifndef _WINDOWS_
  124. #ifndef _FILETIME_
  125. #define _FILETIME_
  126. typedef struct FARSTRUCT tagFILETIME
  127. {
  128. DWORD dwLowDateTime;
  129. DWORD dwHighDateTime;
  130. } FILETIME;
  131. #endif
  132. #endif
  133. /* Storage stat buffer */
  134. typedef struct FARSTRUCT tagSTATSTG
  135. {
  136. char FAR* pwcsName;
  137. DWORD type;
  138. ULARGE_INTEGER cbSize;
  139. FILETIME mtime;
  140. FILETIME ctime;
  141. FILETIME atime;
  142. DWORD grfMode;
  143. DWORD grfLocksSupported;
  144. CLSID clsid;
  145. DWORD grfStateBits;
  146. DWORD reserved;
  147. } STATSTG;
  148. /* Storage element types */
  149. typedef enum tagSTGTY
  150. {
  151. STGTY_STORAGE = 1,
  152. STGTY_STREAM = 2,
  153. STGTY_LOCKBYTES = 3,
  154. STGTY_PROPERTY = 4
  155. } STGTY;
  156. typedef enum tagSTREAM_SEEK
  157. {
  158. STREAM_SEEK_SET = 0,
  159. STREAM_SEEK_CUR = 1,
  160. STREAM_SEEK_END = 2
  161. } STREAM_SEEK;
  162. typedef enum tagLOCKTYPE
  163. {
  164. LOCK_WRITE = 1,
  165. LOCK_EXCLUSIVE = 2,
  166. LOCK_ONLYONCE = 4
  167. } LOCKTYPE;
  168. typedef enum tagSTGMOVE
  169. {
  170. STGMOVE_MOVE = 0,
  171. STGMOVE_COPY = 1
  172. } STGMOVE;
  173. typedef enum tagSTATFLAG
  174. {
  175. STATFLAG_DEFAULT = 0,
  176. STATFLAG_NONAME = 1
  177. } STATFLAG;
  178. /****** Storage Enumerators *************************************************/
  179. #define LPENUMSTATSTG IEnumSTATSTG FAR*
  180. #undef INTERFACE
  181. #define INTERFACE IEnumSTATSTG
  182. DECLARE_INTERFACE_(IEnumSTATSTG, IUnknown)
  183. {
  184. // *** IUnknown methods ***
  185. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  186. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  187. STDMETHOD_(ULONG,Release) (THIS) PURE;
  188. // *** IENUMSTATSTG methods ***
  189. STDMETHOD(Next) (THIS_ ULONG celt, STATSTG FAR * rgelt, ULONG FAR *pceltFetched) PURE;
  190. STDMETHOD(Skip) (THIS_ ULONG celt) PURE;
  191. STDMETHOD(Reset) (THIS) PURE;
  192. STDMETHOD(Clone) (THIS_ IEnumSTATSTG FAR *FAR *ppenm) PURE;
  193. };
  194. /****** ILockBytes Interface ************************************************/
  195. #define LPLOCKBYTES ILockBytes FAR*
  196. #undef INTERFACE
  197. #define INTERFACE ILockBytes
  198. DECLARE_INTERFACE_(ILockBytes, IUnknown)
  199. {
  200. // *** IUnknown methods ***
  201. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  202. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  203. STDMETHOD_(ULONG,Release) (THIS) PURE;
  204. // *** ILockBytes methods ***
  205. STDMETHOD(ReadAt) (THIS_ ULARGE_INTEGER ulOffset,
  206. VOID HUGEP *pv,
  207. ULONG cb,
  208. ULONG FAR *pcbRead) PURE;
  209. STDMETHOD(WriteAt) (THIS_ ULARGE_INTEGER ulOffset,
  210. VOID const HUGEP *pv,
  211. ULONG cb,
  212. ULONG FAR *pcbWritten) PURE;
  213. STDMETHOD(Flush) (THIS) PURE;
  214. STDMETHOD(SetSize) (THIS_ ULARGE_INTEGER cb) PURE;
  215. STDMETHOD(LockRegion) (THIS_ ULARGE_INTEGER libOffset,
  216. ULARGE_INTEGER cb,
  217. DWORD dwLockType) PURE;
  218. STDMETHOD(UnlockRegion) (THIS_ ULARGE_INTEGER libOffset,
  219. ULARGE_INTEGER cb,
  220. DWORD dwLockType) PURE;
  221. STDMETHOD(Stat) (THIS_ STATSTG FAR *pstatstg, DWORD grfStatFlag) PURE;
  222. };
  223. /****** IStream Interface ***************************************************/
  224. #define LPSTREAM IStream FAR*
  225. #undef INTERFACE
  226. #define INTERFACE IStream
  227. DECLARE_INTERFACE_(IStream, IUnknown)
  228. {
  229. // *** IUnknown methods ***
  230. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  231. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  232. STDMETHOD_(ULONG,Release) (THIS) PURE;
  233. // *** IStream methods ***
  234. STDMETHOD(Read) (THIS_ VOID HUGEP *pv,
  235. ULONG cb, ULONG FAR *pcbRead) PURE;
  236. STDMETHOD(Write) (THIS_ VOID const HUGEP *pv,
  237. ULONG cb,
  238. ULONG FAR *pcbWritten) PURE;
  239. STDMETHOD(Seek) (THIS_ LARGE_INTEGER dlibMove,
  240. DWORD dwOrigin,
  241. ULARGE_INTEGER FAR *plibNewPosition) PURE;
  242. STDMETHOD(SetSize) (THIS_ ULARGE_INTEGER libNewSize) PURE;
  243. STDMETHOD(CopyTo) (THIS_ IStream FAR *pstm,
  244. ULARGE_INTEGER cb,
  245. ULARGE_INTEGER FAR *pcbRead,
  246. ULARGE_INTEGER FAR *pcbWritten) PURE;
  247. STDMETHOD(Commit) (THIS_ DWORD grfCommitFlags) PURE;
  248. STDMETHOD(Revert) (THIS) PURE;
  249. STDMETHOD(LockRegion) (THIS_ ULARGE_INTEGER libOffset,
  250. ULARGE_INTEGER cb,
  251. DWORD dwLockType) PURE;
  252. STDMETHOD(UnlockRegion) (THIS_ ULARGE_INTEGER libOffset,
  253. ULARGE_INTEGER cb,
  254. DWORD dwLockType) PURE;
  255. STDMETHOD(Stat) (THIS_ STATSTG FAR *pstatstg, DWORD grfStatFlag) PURE;
  256. STDMETHOD(Clone)(THIS_ IStream FAR * FAR *ppstm) PURE;
  257. };
  258. /****** IStorage Interface **************************************************/
  259. #define LPSTORAGE IStorage FAR*
  260. #undef INTERFACE
  261. #define INTERFACE IStorage
  262. DECLARE_INTERFACE_(IStorage, IUnknown)
  263. {
  264. // *** IUnknown methods ***
  265. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  266. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  267. STDMETHOD_(ULONG,Release) (THIS) PURE;
  268. // *** IStorage methods ***
  269. STDMETHOD(CreateStream) (THIS_ const char FAR* pwcsName,
  270. DWORD grfMode,
  271. DWORD reserved1,
  272. DWORD reserved2,
  273. IStream FAR *FAR *ppstm) PURE;
  274. STDMETHOD(OpenStream) (THIS_ const char FAR* pwcsName,
  275. void FAR *reserved1,
  276. DWORD grfMode,
  277. DWORD reserved2,
  278. IStream FAR *FAR *ppstm) PURE;
  279. STDMETHOD(CreateStorage) (THIS_ const char FAR* pwcsName,
  280. DWORD grfMode,
  281. DWORD reserved1,
  282. DWORD reserved2,
  283. IStorage FAR *FAR *ppstg) PURE;
  284. STDMETHOD(OpenStorage) (THIS_ const char FAR* pwcsName,
  285. IStorage FAR *pstgPriority,
  286. DWORD grfMode,
  287. SNB snbExclude,
  288. DWORD reserved,
  289. IStorage FAR *FAR *ppstg) PURE;
  290. STDMETHOD(CopyTo) (THIS_ DWORD ciidExclude,
  291. IID const FAR *rgiidExclude,
  292. SNB snbExclude,
  293. IStorage FAR *pstgDest) PURE;
  294. STDMETHOD(MoveElementTo) (THIS_ char const FAR* lpszName,
  295. IStorage FAR *pstgDest,
  296. char const FAR* lpszNewName,
  297. DWORD grfFlags) PURE;
  298. STDMETHOD(Commit) (THIS_ DWORD grfCommitFlags) PURE;
  299. STDMETHOD(Revert) (THIS) PURE;
  300. STDMETHOD(EnumElements) (THIS_ DWORD reserved1,
  301. void FAR *reserved2,
  302. DWORD reserved3,
  303. IEnumSTATSTG FAR *FAR *ppenm) PURE;
  304. STDMETHOD(DestroyElement) (THIS_ const char FAR* pwcsName) PURE;
  305. STDMETHOD(RenameElement) (THIS_ const char FAR* pwcsOldName,
  306. const char FAR* pwcsNewName) PURE;
  307. STDMETHOD(SetElementTimes) (THIS_ const char FAR *lpszName,
  308. FILETIME const FAR *pctime,
  309. FILETIME const FAR *patime,
  310. FILETIME const FAR *pmtime) PURE;
  311. STDMETHOD(SetClass) (THIS_ REFCLSID clsid) PURE;
  312. STDMETHOD(SetStateBits) (THIS_ DWORD grfStateBits, DWORD grfMask) PURE;
  313. STDMETHOD(Stat) (THIS_ STATSTG FAR *pstatstg, DWORD grfStatFlag) PURE;
  314. };
  315. /****** IRootStorage Interface **********************************************/
  316. #define LPROOTSTORAGE IRootStorage FAR*
  317. #undef INTERFACE
  318. #define INTERFACE IRootStorage
  319. DECLARE_INTERFACE_(IRootStorage, IUnknown)
  320. {
  321. // *** IUnknown methods ***
  322. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  323. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  324. STDMETHOD_(ULONG,Release) (THIS) PURE;
  325. // *** IRootStorage methods ***
  326. STDMETHOD(SwitchToFile) (THIS_ LPSTR lpstrFile) PURE;
  327. };
  328. /****** Storage API Prototypes ********************************************/
  329. STDAPI StgCreateDocfile(const char FAR* pwcsName,
  330. DWORD grfMode,
  331. DWORD reserved,
  332. IStorage FAR * FAR *ppstgOpen);
  333. STDAPI StgCreateDocfileOnILockBytes(ILockBytes FAR *plkbyt,
  334. DWORD grfMode,
  335. DWORD reserved,
  336. IStorage FAR * FAR *ppstgOpen);
  337. STDAPI StgOpenStorage(const char FAR* pwcsName,
  338. IStorage FAR *pstgPriority,
  339. DWORD grfMode,
  340. SNB snbExclude,
  341. DWORD reserved,
  342. IStorage FAR * FAR *ppstgOpen);
  343. STDAPI StgOpenStorageOnILockBytes(ILockBytes FAR *plkbyt,
  344. IStorage FAR *pstgPriority,
  345. DWORD grfMode,
  346. SNB snbExclude,
  347. DWORD reserved,
  348. IStorage FAR * FAR *ppstgOpen);
  349. STDAPI StgIsStorageFile(const char FAR* pwcsName);
  350. STDAPI StgIsStorageILockBytes(ILockBytes FAR* plkbyt);
  351. STDAPI StgSetTimes(char const FAR* lpszName,
  352. FILETIME const FAR* pctime,
  353. FILETIME const FAR* patime,
  354. FILETIME const FAR* pmtime);
  355. #endif