XPSOF.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:5k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /*
  2.  -  X P S O F . H
  3.  -
  4.  *  Purpose:
  5.  *      Wraps the StreamOnFile object to add buffering of the stream.
  6.  *      The wrappered version uses an in-memory buffer, or cache, to 
  7.  *      reduce the number of actual Reads and Writes to the underlying 
  8.  *      stream.  The goal is, obviously, to improve performance.  
  9.  *
  10.  *  Copyright 1992-1995, Microsoft Corporation.  All Rights Reserved.
  11.  */
  12. #define XPSOF_BUFF_MAX      ((ULONG) 1024)
  13. #define XPSOF_READ          ((ULONG) 0x00000001)
  14. #define XPSOF_WRITE         ((ULONG) 0x00000002)
  15. #define XPSOF_READWRITE     ((ULONG) 0x00000003)
  16. /* Creates the wrapped SOF object */
  17. STDMETHODIMP HrWrapStreamOnFile(
  18.     LPALLOCATEBUFFER    lpAllocBuffer,
  19.     LPFREEBUFFER        lpFreeBuffer,
  20.     ULONG               ulFlags,
  21.     LPSTREAM            lpStream,
  22.     LPSTREAM *          lppWrappedStream);
  23. /* IStream Interface */
  24. #define MAPI_ISTREAM_METHODS(IPURE)                                     
  25.     MAPIMETHOD(Read)                                                    
  26.         (THIS_  VOID HUGEP *                lpv,                        
  27.                 ULONG                       cb,                         
  28.                 ULONG FAR *                 lpcbRead) IPURE;            
  29.     MAPIMETHOD(Write)                                                   
  30.         (THIS_  VOID const HUGEP *          lpv,                        
  31.                 ULONG                       cb,                         
  32.                 ULONG FAR *                 lpcbWritten) IPURE;         
  33.     MAPIMETHOD(Seek)                                                    
  34.         (THIS_  LARGE_INTEGER               libMove,                    
  35.                 DWORD                       dwOrigin,                   
  36.                 ULARGE_INTEGER FAR *        lplibNewPosition) IPURE;    
  37.     MAPIMETHOD(SetSize)                                                 
  38.         (THIS_  ULARGE_INTEGER              libNewSize) IPURE;          
  39.     MAPIMETHOD(CopyTo)                                                  
  40.         (THIS_  IStream FAR *               lpstm,                      
  41.                 ULARGE_INTEGER              cb,                         
  42.                 ULARGE_INTEGER FAR *        lpcbRead,                   
  43.                 ULARGE_INTEGER FAR *        lpcbWritten) IPURE;         
  44.     MAPIMETHOD(Commit)                                                  
  45.         (THIS_  DWORD                       dwCommitFlags) IPURE;       
  46.     MAPIMETHOD(Revert)                                                  
  47.         (THIS)                              IPURE;                      
  48.     MAPIMETHOD(LockRegion)                                              
  49.         (THIS_  ULARGE_INTEGER              libOffset,                  
  50.                 ULARGE_INTEGER              cb,                         
  51.                 DWORD                       dwLockType) IPURE;          
  52.     MAPIMETHOD(UnlockRegion)                                            
  53.         (THIS_  ULARGE_INTEGER              ulibOffset,                 
  54.                 ULARGE_INTEGER              cb,                         
  55.                 DWORD                       dwLockType) IPURE;          
  56.     MAPIMETHOD(Stat)                                                    
  57.         (THIS_  STATSTG FAR *               lpstatstg,                  
  58.                 DWORD                       dwStatFlag) IPURE;          
  59.     MAPIMETHOD(Clone)                                                   
  60.         (THIS_  IStream FAR * FAR *         lppstm) IPURE;              
  61. /* Interface declaration */
  62. #undef  INTERFACE
  63. #define INTERFACE struct _XPSOF
  64. #undef  MAPIMETHOD_
  65. #define MAPIMETHOD_(type, method)   MAPIMETHOD_DECLARE(type, method, XPSOF_)
  66.         MAPI_IUNKNOWN_METHODS(IMPL)
  67.         MAPI_ISTREAM_METHODS(IMPL)
  68. #undef  MAPIMETHOD_
  69. #define MAPIMETHOD_(type, method)   MAPIMETHOD_TYPEDEF(type, method, XPSOF_)
  70.         MAPI_IUNKNOWN_METHODS(IMPL)
  71.         MAPI_ISTREAM_METHODS(IMPL)
  72. #undef  MAPIMETHOD_
  73. #define MAPIMETHOD_(type, method)   STDMETHOD_(type, method)
  74. DECLARE_MAPI_INTERFACE(XPSOF_)
  75. {
  76.     MAPI_IUNKNOWN_METHODS(IMPL)
  77.     MAPI_ISTREAM_METHODS(IMPL)
  78. };
  79. typedef struct _XPSOF
  80. {
  81.     XPSOF_Vtbl *        lpVtbl;
  82.     LONG                lcInit;
  83.     ULONG               ulFlags;
  84.     LPSTREAM            lpstrm;
  85.     LPVOID              lpvBuff;
  86.     ULONG               libBuff;
  87.     ULONG               cbBuffMac;
  88.     BOOL                fDirty;
  89.     LPFREEBUFFER        FreeBuffer;
  90. } XPSOF, FAR * LPXPSOF;