VC++ Extensions 头文件的详细资料

目录

下列头文件 (icrsint.h) 详细说明了允许客户提取一行数据并直接送至类数据成员的接口。客户程序需要在其类中包含绑定条目,以指定 Recordset Field 对象和类数据成员之间的关联。

#ifndef _ICRSINT_H_
#define _ICRSINT_H_#include <olectl.h>
#include <stddef.h>// forwards
class CADORecordBinding;#define classoffset(base, derived) \
   ((DWORD)(static_cast<base*>((derived*)8))-8)enum FieldStatusEnum
{   
   adFldOK = 0,
   adFldBadAccessor = 1,
   adFldCantConvertValue = 2,
   adFldNull = 3,
   adFldTruncated = 4,
   adFldSignMismatch = 5,
   adFldDataOverFlow = 6,
   adFldCantCreate = 7,
   adFldUnavailable = 8,
   adFldPermissionDenied = 9,
   adFldIntegrityViolation = 10,
   adFldSchemaViolation = 11,
   adFldBadStatus = 12,
   adFldDefault = 13
};typedef struct stADO_BINDING_ENTRY
{
   ULONG         ulOrdinal;
   WORD         wDataType;
   BYTE         bPrecision;
   BYTE         bScale;
   ULONG         ulSize;
   ULONG         ulOffSet;
   ULONG         ulIADOBindingEntriesOffSet;
   ULONG         ulFldStatusOffset;
   BOOL         fModify;
} ADO_BINDING_ENTRY;#define BEGIN_ADO_BINDING(cls) public: \
   typedef cls ADORowClass; \
   const ADO_BINDING_ENTRY* STDMETHODCALLTYPE GetADOBindingEntries() { \
   static const ADO_BINDING_ENTRY rgADOBindingEntries[] = { #define ADO_FIXED_LENGTH_BINDING_ENTRY(Ordinal, DataType, Buffer, \   Status, Modify)\
   {Ordinal, \
   DataType, \
   0, \
   0, \
   0, \
   offsetof(ADORowClass, Buffer), \
   classoffset(CADORecordBinding, ADORowClass), \
   offsetof(ADORowClass, Status), \
   Modify},#define ADO_NUMERIC_BINDING_ENTRY(Ordinal, DataType, \
   Buffer, Precision, Scale, Status, Modify)\
   {Ordinal, \
   DataType, \
   Precision, \
   Scale, \
   0, \
   offsetof(ADORowClass, Buffer), \
   classoffset(CADORecordBinding, ADORowClass), \
   offsetof(ADORowClass, Status), \
   Modify},#define ADO_VARIABLE_LENGTH_BINDING_ENTRY(Ordinal, DataType, \
   Buffer, Size, Status, Modify)\
   {Ordinal, \
   DataType, \
   0, \
   0, \
   Size, \
   offsetof(ADORowClass, Buffer), \
   classoffset(CADORecordBinding, ADORowClass), \
   offsetof(ADORowClass, Status), \
   Modify},#define END_ADO_BINDING() {0, adEmpty, 0, 0, 0, 0, 0, adFldOK, FALSE}};\
   return rgADOBindingEntries;}//
// 客户端“record”类需要支持的接口。
// ADO 绑定条目提供执行该接口。 
//
class CADORecordBinding
{
public:
   STDMETHOD_(const ADO_BINDING_ENTRY*, GetADOBindingEntries) 
   (VOID) PURE;
};//
// 接口允许客户程序获取数据记录并传递给类数据成员。
//
DEFINE_GUID(IID_IADORecordBinding, 
            0x00000544, 0, 0x10, 0x80,0,0,0xAA,0,0x6D,0x2E,0xA4);
DECLARE_INTERFACE_(IADORecordBinding, IUnknown)
{
public:
   STDMETHOD(BindToRecordset)(CADORecordBinding *pAdoRecordBinding)PURE;
   STDMETHOD(AddNew)(CADORecordBinding *pAdoRecordBinding) PURE;
   STDMETHOD(Update)(CADORecordBinding *pAdoRecordBinding) PURE;
};#endif // !_ICRSINT_H_
www.holmesian.org