home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / icmprecs.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  47.3 KB  |  1,034 lines

  1. /**************************************************************************************
  2.  **                                                                                  **
  3.  ** ICmpRecs.h - this file is used to give direct access to the storage engine.      **
  4.  **              It bypasses the OLE DB layer.                                       **
  5.  **                                                                                  **
  6.  ** Copyright (c) 1996-2000 Microsoft Corporation.  All Rights Reserved.             **
  7.  **                                                                                  **
  8.  **************************************************************************************/
  9.  
  10.  
  11. #pragma once
  12.  
  13. #ifndef _CORSAVESIZE_DEFINED_
  14. #define _CORSAVESIZE_DEFINED_
  15. enum CorSaveSize
  16. {
  17.     cssAccurate = 0x0000,            // Find exact save size, accurate but slower.
  18.     cssQuick = 0x0001                // Estimate save size, may pad estimate, but faster.
  19. };
  20. #endif
  21.  
  22. #include <basetsd.h>     // BUGBUG VC6.0 hack
  23.  
  24. //********** Types ************************************************************
  25. extern const GUID __declspec(selectany) IID_IComponentRecords =
  26. { 0x259a8e8, 0xcf25, 0x11d1, { 0x8c, 0xcf, 0x0, 0xc0, 0x4f, 0xc3, 0x1d, 0xf8 } };
  27.  
  28. extern const GUID __declspec(selectany) IID_ITSComponentRecords =
  29. { 0x22ad41d1, 0xd96a, 0x11d1, { 0x88, 0xc1, 0x0, 0x80, 0xc7, 0x92, 0xe5, 0xd8 } };
  30.  
  31. extern const GUID __declspec(selectany) IID_IComponentRecordsSchema =
  32. { 0x58769c81, 0xa8cc, 0x11d1, { 0x88, 0x46, 0x0, 0x80, 0xc7, 0x92, 0xe5, 0xd8 } };
  33.  
  34. extern const GUID __declspec(selectany) IID_ITSComponentRecordsSchema =
  35. { 0x22ad41d2, 0xd96a, 0x11d1, { 0x88, 0xc1, 0x0, 0x80, 0xc7, 0x92, 0xe5, 0xd8 } };
  36.  
  37.  
  38. extern const GUID __declspec(selectany) IID_ICallDescrSection =
  39. { 0x2b137007, 0xf02d, 0x11d1, { 0x8c, 0xe3, 0x0, 0xa0, 0xc9, 0xb0, 0xa0, 0x63 } };
  40.  
  41.  
  42. // These data types are basically castable place holders for non-engine code.
  43. #if !defined(__MSCORCLB_CODE__) && !defined(_STGAPI_H_)
  44. class CRCURSOR
  45. {
  46.     char b[32];
  47. };
  48. class RECORDLIST;
  49. #endif
  50.  
  51.  
  52. //*****************************************************************************
  53. // Use the following to give a hint to QueryRowsByColumns.    When passed in, the
  54. // query code will use the index given to do the query.  If a hint is not given,
  55. // then no index is used.  While index choosing code is in the driver (for OLE
  56. // DB clients), internal engine use will be faster if the index is indentified
  57. // up front.
  58. //*****************************************************************************
  59.  
  60. #define QUERYHINT_PK_MULTICOLUMN    0xffffffff // A multiple column primary key.
  61.  
  62. enum QUERYHINTTYPE
  63. {
  64.     QH_COLUMN,                            // Hint is a RID or primary key column.
  65.     QH_INDEX                            // Use the index given.
  66. };
  67.  
  68. struct QUERYHINT
  69. {
  70.     QUERYHINTTYPE    iType;                // What type of hint to use.
  71.     union
  72.     {
  73.         ULONG        columnid;            // Which column contains the hint.
  74.         const char    *szIndex;            // Name of index.
  75.     };
  76. };
  77.  
  78.  
  79. //*****************************************************************************
  80. // Support for IComponentRecordsSchema, which can be used to get the definition
  81. // of a table, its columns, and indexes.
  82. //*****************************************************************************
  83. #ifndef __ICR_SCHEMA__
  84. #define __ICR_SCHEMA__
  85.  
  86. #ifndef __COMPLIB_NAME_LENGTHS__
  87. #define __COMPLIB_NAME_LENGTHS__
  88. const int MAXCOLNAME = 32;
  89. const int MAXSCHEMANAME = 32;
  90. const int MAXINDEXNAME = 32 + MAXSCHEMANAME;
  91. const int MAXTABLENAME = 32 + MAXSCHEMANAME;
  92. const int MAXDESC = 256;
  93. const int MAXTYPENAME = 36;
  94. #endif
  95.  
  96.  
  97. // Each table is described as follows.
  98. struct ICRSCHEMA_TABLE
  99. {
  100.     WCHAR        rcTable[MAXTABLENAME];    // Name of the table.
  101.     ULONG        fFlags;                 // ICRSCHEMA_TBL_xxx flags.
  102.     USHORT        Columns;                // How many columns are in the table.
  103.     USHORT        Indexes;                // How many indexes are in the table.
  104.     USHORT        RecordStart;            // Start offset for a RID column.
  105.     USHORT        Pad;
  106. };
  107.  
  108. #define ICRSCHEMA_TBL_TEMPORARY     0x00000001    // Table is temporary.
  109. #define ICRSCHEMA_TBL_HASPKEYCOL    0x00000008    // Table has a primary key.
  110. #define ICRSCHEMA_TBL_HASRIDCOL     0x00000010    // Table has a RID column.
  111. #define ICRSCHEMA_TBL_MASK            0x00000019
  112.  
  113. // Each column is described by the following structure.
  114. struct ICRSCHEMA_COLUMN
  115. {
  116.     WCHAR        rcColumn[MAXCOLNAME];    // Name of the column.
  117.     DBTYPE        wType;                    // Type of column.
  118.     USHORT        Ordinal;                // Ordinal of this column.
  119.     ULONG        fFlags;                 // ICRSCHEMA_COL_xxx flags
  120.     ULONG        cbSize;                 // Maximum size a column can be.
  121. };
  122.  
  123. #define ICRSCHEMA_COL_NULLABLE        0x00000001    // Column allows the NULL value.
  124. #define ICRSCHEMA_COL_PK            0x00000004    // Primary key column.
  125. #define ICRSCHEMA_COL_ROWID         0x00000008    // Column is the record id for table.
  126. #define ICRSCHEMA_COL_FIXEDLEN        0x00001000    // Column is fixed length.
  127. #define ICRSCHEMA_COL_MASK            0x0000100D
  128.  
  129.  
  130. // Each index can be retrieved using this structure.  The Keys field conains
  131. // the size of the rgKeys array on input, and on output contains the total
  132. // number of keys on the index.  If the size is larger on return then going
  133. // in, the array was not large enough.    Simply call again wtih an array of
  134. // the correct size to get the total list.
  135. struct ICRSCHEMA_INDEX
  136. {
  137.     WCHAR        rcIndex[MAXINDEXNAME];    // Name of the index.
  138.     ULONG        fFlags;                 // Flags describing the index.
  139.     USHORT        RowThreshold;            // Minimum rows required before index is built.
  140.     USHORT        IndexOrdinal;            // Ordinal of the index.
  141.     USHORT        Type;                    // What type of index is this.
  142.     USHORT        Keys;                    // [In] Max size of rgKeys, [Out] Total keys there are
  143.     USHORT        *rgKeys;                // Array of key values to fill out.
  144. };
  145.  
  146. enum
  147. {
  148.     ICRSCHEMA_TYPE_HASHED            = 0x01,     // Hashed index.
  149.     ICRSCHEMA_TYPE_SORTED            = 0x02        // Sorted index.
  150. };
  151.  
  152. #define ICRSCHEMA_DEX_UNIQUE        0x00000002    // Unique index.
  153. #define ICRSCHEMA_DEX_PK            0x00000004    // Primary key.
  154. #define ICRSCHEMA_DEX_MASK            0x00000006    // Mask.
  155.  
  156.  
  157. // Used for GetColumnDefinitions.
  158. enum ICRCOLUMN_GET
  159. {
  160.     ICRCOLUMN_GET_ALL,                    // Retrieve every column.
  161.     ICRCOLUMN_GET_BYORDINAL             // Retrieve according to ordinal.
  162. };
  163.  
  164. #endif // __ICR_SCHEMA__
  165.  
  166.  
  167. //*****************************************************************************
  168. // Flags for record creation.
  169. //*****************************************************************************
  170. #define ICR_RECORD_NORMAL    0x00000000            // Normal, persisted record (default).
  171. #define ICR_RECORD_TEMP        0x00000001            // Record is transient.
  172.  
  173.  
  174.  
  175.  
  176. //********** Macros ***********************************************************
  177.  
  178. //*****************************************************************************
  179. // Helper macros for Set/GetColumns, Set/GetStruct.
  180. //*****************************************************************************
  181. #ifndef __ColumnBitMacros__
  182. #define __ColumnBitMacros__
  183. #define CheckColumnBit(flags, x)    (flags & (1 << x))
  184. #define SetColumnBit(x)             (1 << x)
  185. #define UnsetColumnBit(x)            (~(1 << x))
  186.  
  187. #define COLUMN_ORDINAL_MASK            0x80000000
  188. #define COLUMN_ORDINAL_LIST(x)        (COLUMN_ORDINAL_MASK | x)
  189. inline int IsOrdinalList(ULONG i)
  190. {
  191.     return ((COLUMN_ORDINAL_MASK & i) == COLUMN_ORDINAL_MASK);
  192. }
  193. #endif
  194.  
  195. inline ULONG SetBit(ULONG &val, int iBit, int bSet)
  196. {
  197.     if (bSet)
  198.         val |= (1 << iBit);
  199.     else
  200.         val &= ~(1 << iBit);
  201.     return (val);
  202. }
  203.  
  204. inline ULONG GetBit(ULONG val, int iBit)
  205. {
  206.     return (val & (1 << iBit));
  207. }
  208.  
  209. #ifdef _M_ALPHA
  210. #define DEFAULT_ALIGNMENT            8
  211. #else
  212. #define DEFAULT_ALIGNMENT            4
  213. #endif
  214. #define DFT_MAX_VARCOL                260
  215.  
  216. #define MAXSHMEM                    32
  217.  
  218. //*****************************************************************************
  219. // This interface is access special data from a record (ie: data that could
  220. // be variable sized or otherwise changed).
  221. //*****************************************************************************
  222. interface IComponentRecords : public IUnknown
  223. {
  224.  
  225. //*****************************************************************************
  226. //
  227. //********** Record creation functions.
  228. //
  229. //*****************************************************************************
  230.  
  231.     virtual HRESULT STDMETHODCALLTYPE NewRecord( // Return code.
  232.         TABLEID     tableid,                // Which table to work on.
  233.         void        **ppData,                // Return new record here.
  234.         OID         _oid,                    // ID of the record.
  235.         ULONG        iOidColumn,             // Ordinal of OID column, 0 means none.
  236.         ULONG        *pRecordID) = 0;        // Optionally return the record id.
  237.  
  238.     virtual HRESULT STDMETHODCALLTYPE NewTempRecord( // Return code.
  239.         TABLEID     tableid,                // Which table to work on.
  240.         void        **ppData,                // Return new record here.
  241.         OID         _oid,                    // ID of the record.
  242.         ULONG        iOidColumn,             // Ordinal of OID column.
  243.         ULONG        *pRecordID) = 0;        // Optionally return the record id.
  244.  
  245. //*****************************************************************************
  246. // This function will insert a new record into the given table and set all of
  247. // the data for the columns.  In cases where a primary key and/or unique indexes
  248. // need to be specified, this is the only function that can be used.
  249. //
  250. // Please see the SetColumns function for a description of the rest of the
  251. // parameters to this function.
  252. //*****************************************************************************
  253.     virtual HRESULT STDMETHODCALLTYPE NewRecordAndData( // Return code.
  254.         TABLEID     tableid,                // Which table to work on.
  255.         void        **ppData,                // Return new record here.
  256.         ULONG        *pRecordID,             // Optionally return the record id.
  257.         int            fFlags,                    // ICR_RECORD_xxx value, 0 default.
  258.         int         iCols,                    // number of columns
  259.         const DBTYPE rgiType[],             // data types of the columns.
  260.         const void    *rgpbBuf[],             // pointers to where the data will be stored.
  261.         const ULONG cbBuf[],                // sizes of the data buffers.
  262.         ULONG        pcbBuf[],                // size of data available to be returned.
  263.         HRESULT     rgResult[],             // [in] DBSTATUS_S_ISNULL array [out] HRESULT array.
  264.         const ULONG    *rgFieldMask) = 0;        // IsOrdinalList(iCols) 
  265.                                             //    ? an array of 1 based ordinals
  266.                                             //    : a bitmask of columns
  267.  
  268.  
  269.  
  270. //*****************************************************************************
  271. //
  272. //********** Full struct functions.  The SchemaGen tool will generate a
  273. //                structure for a table that matches the full layout.  Use these
  274. //                structures with the following functions to do very fast get, set,
  275. //                and inserts of data without binding information.
  276. //
  277. //*****************************************************************************
  278.  
  279. //**************************************************************************************
  280. // GetStruct
  281. //        Retrieve the fields specified by fFieldMask, for the array of iRows row pointers
  282. //        of size cbRowStruct and place it into the memory chunk pointed to by rgpbBuf.
  283. //        rgResult[] is any array of the HRESULTs for each row if the user is interested in
  284. //        knowing.
  285. //        The function will bail out on the first error. In this case it is the
  286. //        responsibility of the user to walk through the rgResults[] array to figure out
  287. //        when the error happened. Warnings generated by the lower level functions are placed
  288. //        rgResults[] array, but the function continues with the next row.
  289. //
  290. //**************************************************************************************
  291.     virtual HRESULT STDMETHODCALLTYPE GetStruct(    //Return Code
  292.         TABLEID     tableid,                // Which table to work on.
  293.         int         iRows,                    // number of rows for bulk fetch.
  294.         void        *rgpRowPtr[],            // pointer to array of row pointers.
  295.         int         cbRowStruct,            // size of <table name>_RS structure.
  296.         void        *rgpbBuf,                // pointer to the chunk of memory where the
  297.                                             // retrieved data will be placed.
  298.         HRESULT     rgResult[],             // array of HRESULT for iRows.
  299.         ULONG        fFieldMask) = 0;        // mask to specify a subset of fields.
  300.  
  301. //**************************************************************************************
  302. // SetStruct:
  303. //        given an array of iRows row pointers, set the data the user provided in the
  304. //        specified fields of the row. cbRowStruct has been provided
  305. //        to be able to embed the RowStruct (as defined by pagedump) in a user defined structure.
  306. //        fNullFieldMask specifies fields that the user wants to set to NULL.
  307. //        The user provides rgResult[] array if interested in the outcome of each row.
  308. //
  309. //**************************************************************************************
  310.     virtual HRESULT STDMETHODCALLTYPE SetStruct(    // Return Code
  311.         TABLEID     tableid,                // table to work on.
  312.         int         iRows,                    // number of Rows for bulk set.
  313.         void        *rgpRowPtr[],            // pointer to array of row pointers.
  314.         int         cbRowStruct,            // size of <table name>_RS struct.
  315.         void        *rgpbBuf,                // pointer to chunk of memory to set the data from.
  316.         HRESULT     rgResult[],             // array of HRESULT for iRows.
  317.         ULONG        fFieldMask,             // mask to specify a subset of the fields.
  318.         ULONG        fNullFieldMask) = 0;    // fields which need to be set to null.
  319.  
  320. //**************************************************************************************
  321. // InsertStruct:
  322. //        Creates new records first and then calls SetStruct.
  323. //        See SetStruct() for details on the parameters.
  324. //**************************************************************************************
  325.     virtual HRESULT STDMETHODCALLTYPE InsertStruct( // Return Code
  326.         TABLEID     tableid,                // table to work on.
  327.         int         iRows,                    // number of Rows for bulk set.
  328.         void        *rgpRowPtr[],            // Return pointer to new values.
  329.         int         cbRowStruct,            // size of <table name>_RS struct.
  330.         void        *rgpbBuf,                // pointer to chunk of memory to set the data from.
  331.         HRESULT     rgResult[],             // array of HRESULT for iRows.
  332.         ULONG        fFieldMask,             // mask to specify a subset of the fields.
  333.         ULONG        fNullFieldMask) = 0;    // fields which need to be set to null.
  334.  
  335.  
  336.  
  337. //*****************************************************************************
  338. //
  339. //********** Generic column get and set functions.    Provides fast get and set
  340. //                speed for many columns in your own layout.
  341. //
  342. //*****************************************************************************
  343.  
  344. //*****************************************************************************
  345. // Similar to GetStruct(), this function retrieves the specified columns 
  346. // of 1 record pointer. The major difference between GetColumns() and 
  347. // GetStruct() is that GetColumns() let's the caller specify a individual 
  348. // buffer for each field. Hence, the caller does not have to allocate the row 
  349. // structure like you would with GetStruct(). Refer to the GetStruct() header 
  350. // for details on the parameters.
  351. //
  352. // fFieldMask can be one of two types.  If you apply the COLUMN_ORDINAL_LIST
  353. // macro to the iCols parameter, then fFieldMask points to an array of 
  354. // ULONG column ordinals.  This consumes more room, but allows column ordinals
  355. // greater than 32.  If the macro is not applied to the count, then fFieldMask
  356. // is a pointer to a bitmaks of columns which are to be touched.  Use the
  357. // SetColumnBit macro to set the correct bits.
  358. //
  359. // DBTYPE_BYREF may be given for the data type on the get.    In this case, 
  360. // rgpbBuf will the address of an array of void * pointers that will be filled
  361. // out with pointers to the actual data for the column.  These pointers point
  362. // to the internal data structures of the engine and must never be written to.
  363. // If the column was null, then the pointer value will be set to NULL.    Finally,
  364. // the pcbBuf entry for the column contains the length of the data pointed to
  365. // by rgpbBuf.
  366. //*****************************************************************************
  367.     virtual HRESULT STDMETHODCALLTYPE GetColumns(    // Return code.
  368.         TABLEID     tableid,                // table to work on.
  369.         const void    *pRowPtr,                // row pointer
  370.         int         iCols,                    // number of columns
  371.         const DBTYPE rgiType[],             // data types of the columns.
  372.         const void    *rgpbBuf[],             // pointers to where the data will be stored.
  373.         ULONG        cbBuf[],                // sizes of the data buffers.
  374.         ULONG        pcbBuf[],                // size of data available to be returned.
  375.         HRESULT     rgResult[],             // array of HRESULT for iCols.
  376.         const ULONG    *rgFieldMask) = 0;        // IsOrdinalList(iCols) 
  377.                                             //    ? an array of 1 based ordinals
  378.                                             //    : a bitmask of columns
  379.  
  380. //*****************************************************************************
  381. // Similar to SetStruct(), this function puts the specified columns of 1 record
  382. // pointer. The major difference between SetColumns() and SetStruct() is that 
  383. // SetColumns() let's the caller specify a individual buffer for each field. 
  384. // Hence, the caller does not have to allocate the row structure like you would 
  385. // with SetStruct(). Refer to the SetStruct() hearder for details on the 
  386. // parameters.
  387. //
  388. // fFieldMask can be one of two types.  If you apply the COLUMN_ORDINAL_LIST
  389. // macro to the iCols parameter, then fFieldMask points to an array of 
  390. // ULONG column ordinals.  This consumes more room, but allows column ordinals
  391. // greater than 32.  If the macro is not applied to the count, then fFieldMask
  392. // is a pointer to a bitmaks of columns which are to be touched.  Use the
  393. // SetColumnBit macro to set the correct bits.
  394. //
  395. // DBTYPE_BYREF is not allowed by this function since this function must 
  396. // always make a copy of the data for it to be saved to disk with the database.
  397. //*****************************************************************************
  398.     virtual HRESULT STDMETHODCALLTYPE SetColumns(    // Return code.
  399.         TABLEID     tableid,                // table to work on.
  400.         void        *pRowPtr,                // row pointer
  401.         int         iCols,                    // number of columns
  402.         const DBTYPE rgiType[],             // data types of the columns.
  403.         const void    *rgpbBuf[],             // pointers to where the data will be stored.
  404.         const ULONG cbBuf[],                // sizes of the data buffers.
  405.         ULONG        pcbBuf[],                // size of data available to be returned.
  406.         HRESULT     rgResult[],             // [in] CLDB_S_NULL array [out] HRESULT array.
  407.         const ULONG    *rgFieldMask) = 0;        // IsOrdinalList(iCols) 
  408.                                             //    ? an array of 1 based ordinals
  409.                                             //    : a bitmask of columns
  410.  
  411.  
  412.  
  413.  
  414. //*****************************************************************************
  415. //
  416. //********** Query functions.
  417. //
  418. //*****************************************************************************
  419.  
  420.     virtual HRESULT STDMETHODCALLTYPE GetRecordCount( // Return code.
  421.         TABLEID     tableid,                // Which table to work on.
  422.         ULONG        *piCount) = 0;            // Not including deletes.
  423.  
  424.     virtual HRESULT STDMETHODCALLTYPE GetRowByOid( // Return code.
  425.         TABLEID     tableid,                // Which table to work with.
  426.         OID         _oid,                    // Value for keyed lookup.
  427.         ULONG        iColumn,                // 1 based column number (logical).
  428.         void        **ppStruct) = 0;        // Return pointer to record.
  429.  
  430.     virtual HRESULT STDMETHODCALLTYPE GetRowByRID( // Return code.
  431.         TABLEID     tableid,                // Which table to work with.
  432.         ULONG        rid,                    // Record id.
  433.         void        **ppStruct) = 0;        // Return pointer to record.
  434.  
  435.     virtual HRESULT STDMETHODCALLTYPE GetRIDForRow( // Return code.
  436.         TABLEID     tableid,                // Which table to work with.
  437.         const void    *pRecord,                // The record we want RID for.
  438.         ULONG        *pirid) = 0;            // Return the RID for the given row.
  439.  
  440.     virtual HRESULT STDMETHODCALLTYPE GetRowByColumn( // S_OK, CLDB_E_RECORD_NOTFOUND, error.
  441.         TABLEID     tableid,                // Which table to work with.
  442.         ULONG        iColumn,                // 1 based column number (logical).
  443.         const void    *pData,                 // User data.
  444.         ULONG         cbData,                 // Size of data (blobs)
  445.         DBTYPE        iType,                    // What type of data given.
  446.         void        *rgRecords[],            // Return array of records here.
  447.         int         iMaxRecords,            // Max that will fit in rgRecords.
  448.         RECORDLIST    *pRecords,                // If variable rows desired.
  449.         int         *piFetched) = 0;        // How many records were fetched.
  450.  
  451. //*****************************************************************************
  452. // This query function allows you to do lookups on one or more column at a
  453. // time.  It does not expose the full OLE DB view-filter mechanism which is
  454. // very flexible, but rather exposes multiple column AND conditions with
  455. // equality.  A record must match all of the criteria to be returned to
  456. // in the cursor.
  457. //
  458. // User data - For each column, rgiColumn, rgpbData, and rgiType contain the
  459. //        pointer information to the user data to filter on.
  460. //
  461. // Query hints - Queries will run faster if it is known that some of the
  462. //        columns are indexed.  While there is code in the engine to scan query
  463. //        lists for target indexes, this internal function bypasses that code in
  464. //        favor of performance.  If you know that a column is a RID or PK, or that
  465. //        there is an index, then these columns need to be the first set passed
  466. //        in.  Fill out a QUERYHINT and pass this value in.  Pass NULL if you
  467. //        know there is no index information, and the table will be scanned.
  468. //
  469. //        Note that you may follow indexes columns with non-indexed columns,
  470. //        in which case all records in the index are found first, and then those
  471. //        are scanned for the rest of the criteria.
  472. //
  473. // Returned cursor - Data may be returned in two mutually exclusive ways:
  474. //        (1) Pass an array of record pointers in rgRecords and set iMaxRecords
  475. //            to the count of this array.  Only that many rows are brought back.
  476. //            This requires to heap allocations and is good for cases where you
  477. //            can predict cardinality up front.
  478. //        (2) Pass the address of a CRCURSOR to get a dynamic list.  Then use
  479. //            the cursor functions on this interface to fetch data and close
  480. //            the cursor.
  481. //*****************************************************************************
  482.     virtual HRESULT STDMETHODCALLTYPE QueryByColumns( // S_OK, CLDB_E_RECORD_NOTFOUND, error.
  483.         TABLEID     tableid,                // Which table to work with.
  484.         const QUERYHINT *pQryHint,            // What index to use, NULL valid.
  485.         int         iColumns,                // How many columns to query on.
  486.         const ULONG rgiColumn[],            // 1 based column numbers.
  487.         const DBCOMPAREOP rgfCompare[],     // Comparison operators, NULL means ==.
  488.         const void    *rgpbData[],            // User data.
  489.         const ULONG rgcbData[],             // Size of data (blobs)
  490.         const DBTYPE rgiType[],             // What type of data given.
  491.         void        *rgRecords[],            // Return array of records here.
  492.         int         iMaxRecords,            // Max that will fit in rgRecords.
  493.         CRCURSOR    *psCursor,                // Buffer for the cursor handle.
  494.         int         *piFetched) = 0;        // How many records were fetched.
  495.  
  496.     virtual HRESULT STDMETHODCALLTYPE OpenCursorByColumn( // Return code.
  497.         TABLEID     tableid,                // Which table to work with.
  498.         ULONG        iColumn,                // 1 based column number (logical).
  499.         const void    *pData,                 // User data.
  500.         ULONG        cbData,                 // Size of data (blobs)
  501.         DBTYPE        iType,                    // What type of data given.
  502.         CRCURSOR    *psCursor) = 0;         // Buffer for the cursor handle.
  503.  
  504.  
  505.  
  506. //*****************************************************************************
  507. //
  508. //********** Cursor manipulation functions.
  509. //
  510. //*****************************************************************************
  511.  
  512.  
  513. //*****************************************************************************
  514. // Reads the next set of records from the cursor into the given buffer.
  515. //*****************************************************************************
  516.     virtual HRESULT STDMETHODCALLTYPE ReadCursor(// Return code.
  517.         CRCURSOR    *psCursor,                // The cursor handle.
  518.         void        *rgRecords[],            // Return array of records here.
  519.         int         *piRecords) = 0;        // Max that will fit in rgRecords.
  520.  
  521. //*****************************************************************************
  522. // Move the cursor location to the index given.  The next ReadCursor will start
  523. // fetching records at that index.
  524. //*****************************************************************************
  525.     virtual HRESULT STDMETHODCALLTYPE MoveTo( // Return code.
  526.         CRCURSOR    *psCursor,                // The cursor handle.
  527.         ULONG        iIndex) = 0;            // New index.
  528.  
  529. //*****************************************************************************
  530. // Get the count of items in the cursor.
  531. //*****************************************************************************
  532.     virtual HRESULT STDMETHODCALLTYPE GetCount( // Return code.
  533.         CRCURSOR    *psCursor,                // The cursor handle.
  534.         ULONG        *piCount) = 0;            // Return the count.
  535.  
  536. //*****************************************************************************
  537. // Close the cursor and clean up the resources we've allocated.
  538. //*****************************************************************************
  539.     virtual HRESULT STDMETHODCALLTYPE CloseCursor(// Return code.
  540.         CRCURSOR    *psCursor) = 0;         // The cursor handle.
  541.  
  542.  
  543.  
  544. //*****************************************************************************
  545. //
  546. //********** Singleton get and put functions for heaped data types.
  547. //
  548. //*****************************************************************************
  549.  
  550.     virtual HRESULT STDMETHODCALLTYPE GetStringUtf8( // Return code.
  551.         TABLEID     tableid,                // Which table to work with.
  552.         ULONG        iColumn,                // 1 based column number (logical).
  553.         const void    *pRecord,                // Record with data.
  554.         LPCSTR        *pszOutBuffer) = 0;     // Where put string pointer.
  555.  
  556.     virtual HRESULT STDMETHODCALLTYPE GetStringA( // Return code.
  557.         TABLEID     tableid,                // Which table to work with.
  558.         ULONG        iColumn,                // 1 based column number (logical).
  559.         const void    *pRecord,                // Record with data.
  560.         LPSTR        szOutBuffer,            // Where to write string.
  561.         int         cchOutBuffer,            // Max size, including room for \0.
  562.         int         *pchString) = 0;        // Size of string is put here.
  563.  
  564.     virtual HRESULT STDMETHODCALLTYPE GetStringW( // Return code.
  565.         TABLEID     tableid,                // Which table to work with.
  566.         ULONG        iColumn,                // 1 based column number (logical).
  567.         const void    *pRecord,                // Record with data.
  568.         LPWSTR        szOutBuffer,            // Where to write string.
  569.         int         cchOutBuffer,            // Max size, including room for \0.
  570.         int         *pchString) = 0;        // Size of string is put here.
  571.  
  572.     virtual HRESULT STDMETHODCALLTYPE GetBstr( // Return code.
  573.         TABLEID     tableid,                // Which table to work with.
  574.         ULONG        iColumn,                // 1 based column number (logical).
  575.         const void    *pRecord,                // Record with data.
  576.         BSTR        *pBstr) = 0;            // Output for bstring on success.
  577.  
  578.     virtual HRESULT STDMETHODCALLTYPE GetBlob( // Return code.
  579.         TABLEID     tableid,                // Which table to work with.
  580.         ULONG        iColumn,                // 1 based column number (logical).
  581.         const void    *pRecord,                // Record with data.
  582.         BYTE        *pOutBuffer,            // Where to write blob.
  583.         ULONG        cbOutBuffer,            // Size of output buffer.
  584.         ULONG        *pcbOutBuffer) = 0;     // Return amount of data available.
  585.  
  586.     virtual HRESULT STDMETHODCALLTYPE GetBlob( // Return code.
  587.         TABLEID        tableid,                // Which table to work with.
  588.         ULONG        iColumn,                // 1 based column number (logical).
  589.         const void    *pRecord,                // Record with data.
  590.         const BYTE    **ppBlob,                // Pointer to blob.
  591.         ULONG        *pcbSize) = 0;            // Size of blob.
  592.  
  593.     virtual HRESULT STDMETHODCALLTYPE GetOid( // Return code.
  594.         TABLEID     tableid,                // Which table to work with.
  595.         ULONG        iColumn,                // 1 based column number (logical).
  596.         const void    *pRecord,                // Record with data.
  597.         OID         *poid) = 0;             // Return id here.
  598.  
  599.     virtual HRESULT STDMETHODCALLTYPE GetVARIANT( // Return code.
  600.         TABLEID     tableid,                // Which table to work with.
  601.         ULONG        iColumn,                // 1 based column number (logical).
  602.         const void    *pRecord,                // Record with data.
  603.         VARIANT     *pValue) = 0;            // The variant to write.
  604.  
  605.     // Retrieve a variant column that contains a blob.
  606.     virtual HRESULT STDMETHODCALLTYPE GetVARIANT( // Return code.
  607.         TABLEID     tableid,                // Which table to work with.
  608.         ULONG        iColumn,                // 1 based column number (logical).
  609.         const void    *pRecord,                // Record with data.
  610.         const void    **ppBlob,                // Put pointer to blob here.
  611.         ULONG        *pcbSize) = 0;            // Put Size of blob.
  612.  
  613.     virtual HRESULT STDMETHODCALLTYPE GetVARIANTType( // Return code.
  614.         TABLEID     tableid,                // Which table to work with.
  615.         ULONG        iColumn,                // 1 based column number (logical).
  616.         const void    *pRecord,                // Record with data.
  617.         VARTYPE     *pType) = 0;            // Put variant type here.
  618.  
  619.     virtual HRESULT STDMETHODCALLTYPE GetGuid( // Return code.
  620.         TABLEID     tableid,                // Which table to work with.
  621.         ULONG        iColumn,                // 1 based column number (logical).
  622.         const void    *pRecord,                // Record with data.
  623.         GUID        *pGuid) = 0;            // Return guid here.
  624.  
  625.     virtual HRESULT STDMETHODCALLTYPE IsNull( // S_OK yes, S_FALSE no.
  626.         TABLEID     tableid,                // Which table to work with.
  627.         const void    *pRecord,                // Record with data.
  628.         ULONG        iColumn) = 0;            // 1 based column number (logical).
  629.  
  630.     virtual HRESULT STDMETHODCALLTYPE PutStringUtf8( // Return code.
  631.         TABLEID     tableid,                // Which table to work with.
  632.         ULONG        iColumn,                // 1 based column number (logical).
  633.         void        *pRecord,                // Record with data.
  634.         LPCSTR        szString,                // String we are writing.
  635.         int         cbBuffer) = 0;            // Bytes in string, -1 null terminated.
  636.  
  637.     virtual HRESULT STDMETHODCALLTYPE PutStringA( // Return code.
  638.         TABLEID     tableid,                // Which table to work with.
  639.         ULONG        iColumn,                // 1 based column number (logical).
  640.         void        *pRecord,                // Record with data.
  641.         LPCSTR        szString,                // String we are writing.
  642.         int         cbBuffer) = 0;            // Bytes in string, -1 null terminated.
  643.  
  644.     virtual HRESULT STDMETHODCALLTYPE PutStringW( // Return code.
  645.         TABLEID     tableid,                // Which table to work with.
  646.         ULONG        iColumn,                // 1 based column number (logical).
  647.         void        *pRecord,                // Record with data.
  648.         LPCWSTR     szString,                // String we are writing.
  649.         int         cbBuffer) = 0;            // Bytes (not characters) in string, -1 null terminated.
  650.  
  651.     virtual HRESULT STDMETHODCALLTYPE PutBlob( // Return code.
  652.         TABLEID        tableid,                // Which table to work with.
  653.         ULONG        iColumn,                // 1 based column number (logical).
  654.         void        *pRecord,                // Record with data.
  655.         const BYTE    *pBuffer,                // User data.
  656.         ULONG        cbBuffer) = 0;            // Size of buffer.
  657.  
  658.     virtual HRESULT STDMETHODCALLTYPE PutOid( // Return code.
  659.         TABLEID     tableid,                // Which table to work with.
  660.         ULONG        iColumn,                // 1 based column number (logical).
  661.         void        *pRecord,                // Record with data.
  662.         OID         oid) = 0;                // Return id here.
  663.  
  664.     virtual HRESULT STDMETHODCALLTYPE PutVARIANT( // Return code.
  665.         TABLEID     tableid,                // Which table to work with.
  666.         ULONG        iColumn,                // 1 based column number (logical).
  667.         void        *pRecord,                // Record with data.
  668.         const VARIANT *pValue) = 0;         // The variant to write.
  669.  
  670.     // Store a blob in a variant column.
  671.     virtual HRESULT STDMETHODCALLTYPE PutVARIANT( // Return code.
  672.         TABLEID     tableid,                // Which table to work with.
  673.         ULONG        iColumn,                // 1 based column number (logical).
  674.         void        *pRecord,                // Record with data.
  675.         const void    *pBuffer,                // User data.
  676.         ULONG        cbBuffer) = 0;            // Size of buffer.
  677.  
  678.     virtual HRESULT STDMETHODCALLTYPE PutVARIANT( // Return code.
  679.         TABLEID     tableid,                // Which table to work with.
  680.         ULONG        iColumn,                // 1 based column number (logical).
  681.         void        *pRecord,                // Record with data.
  682.         VARTYPE     vt,                     // Type of data.
  683.         const void    *pValue) = 0;            // The actual data.
  684.  
  685.     virtual HRESULT STDMETHODCALLTYPE PutGuid( // Return code.
  686.         TABLEID     tableid,                // Which table to work with.
  687.         ULONG        iColumn,                // 1 based column number (logical).
  688.         void        *pRecord,                // Record with data.
  689.         REFGUID     guid) = 0;                // Guid to put.
  690.  
  691.     virtual void STDMETHODCALLTYPE SetNull(
  692.         TABLEID     tableid,                // Which table to work with.
  693.         void        *pRecord,                // Record with data.
  694.         ULONG        iColumn) = 0;            // 1 based column number (logical).
  695.  
  696.     virtual HRESULT STDMETHODCALLTYPE DeleteRowByRID(
  697.         TABLEID     tableid,                // Which table to work with.
  698.         ULONG        rid) = 0;                // Record id.
  699.  
  700.     virtual HRESULT STDMETHODCALLTYPE GetCPVARIANT( // Return code.
  701.         USHORT        ixCP,                    // 1 based Constant Pool index.
  702.         VARIANT     *pValue) = 0;            // Put the data here.
  703.  
  704.     virtual HRESULT STDMETHODCALLTYPE AddCPVARIANT( // Return code.
  705.         VARIANT     *pValue,                // The variant to write.
  706.         ULONG        *pixCP) = 0;            // Put 1 based Constant Pool index here.
  707.  
  708.  
  709. //*****************************************************************************
  710. //
  711. //********** Schema functions.
  712. //
  713. //*****************************************************************************
  714.  
  715.  
  716. //*****************************************************************************
  717. // Add a refernece to the given schema to the database we have open right now
  718. // You must have the database opened for write for this to work.  If this
  719. // schema extends another schema, then that schema must have been added first
  720. // or an error will occur.    It is not an error to add a schema when it was
  721. // already in the database.
  722. //
  723. // Adding a new version of a schema to the current file is not supported in the
  724. // '98 product.  In the future this ability will be added and will invovle a
  725. // forced migration of the current file into the new format.
  726. //*****************************************************************************
  727.     virtual HRESULT STDMETHODCALLTYPE SchemaAdd( // Return code.
  728.         const COMPLIBSCHEMABLOB *pSchema) = 0;    // The schema to add.
  729.  
  730. //*****************************************************************************
  731. // Deletes a reference to a schema from the database.  You must have opened the
  732. // database in write mode for this to work.  An error is returned if another
  733. // schema still exists in the file which extends the schema you are trying to
  734. // remove.    To fix this problem remove any schemas which extend you first.
  735. // All of the table data associated with this schema will be purged from the
  736. // database on Save, so use this function very carefully.
  737. //*****************************************************************************
  738.     virtual HRESULT STDMETHODCALLTYPE SchemaDelete( // Return code.
  739.         const COMPLIBSCHEMABLOB *pSchema) = 0;    // The schema to add.
  740.  
  741. //*****************************************************************************
  742. // Returns the list of schema references in the current database.  Only
  743. // iMaxSchemas can be returned to the caller.  *piTotal tells how many were
  744. // actually copied.  If all references schemas were returned in the space
  745. // given, then S_OK is returned.  If there were more to return, S_FALSE is
  746. // returned and *piTotal contains the total number of entries the database has.
  747. // The caller may then make the array of that size and call the function again
  748. // to get all of the entries.
  749. //*****************************************************************************
  750.     virtual HRESULT STDMETHODCALLTYPE SchemaGetList( // S_OK, S_FALSE, or error.
  751.         int         iMaxSchemas,            // How many can rgSchema handle.
  752.         int         *piTotal,                // Return how many we found.
  753.         COMPLIBSCHEMADESC rgSchema[]) = 0;    // Return list here.
  754.  
  755. //*****************************************************************************
  756. // Before you can work with a table, you must retrieve its TABLEID.  The
  757. // TABLEID changes for each open of the database.  The ID should be retrieved
  758. // only once per open, there is no check for a double open of a table.
  759. // Doing multiple opens will cause unpredictable results.
  760. //*****************************************************************************
  761.     virtual HRESULT STDMETHODCALLTYPE OpenTable( // Return code.
  762.         const COMPLIBSCHEMA *pSchema,        // Schema identifier.
  763.         ULONG        iTableNum,                // Table number to open.
  764.         TABLEID     *pTableID) = 0;         // Return ID on successful open.
  765.  
  766.  
  767. //*****************************************************************************
  768. //
  769. //********** Save/open functions.
  770. //
  771. //*****************************************************************************
  772.  
  773. //*****************************************************************************
  774. // Figures out how big the persisted version of the current scope would be.
  775. // This is used by the linker to save room in the PE file format.  After
  776. // calling this function, you may only call the SaveToStream or Save method.
  777. // Any other function will product unpredictable results.
  778. //*****************************************************************************
  779.     virtual HRESULT STDMETHODCALLTYPE GetSaveSize(
  780.         CorSaveSize fSave,                    // cssQuick or cssAccurate.
  781.         DWORD        *pdwSaveSize) = 0;        // Return size of saved item.
  782.  
  783.     virtual HRESULT STDMETHODCALLTYPE SaveToStream(// Return code.
  784.         IStream     *pIStream) = 0;         // Where to save the data.
  785.  
  786.     virtual HRESULT STDMETHODCALLTYPE Save( // Return code.
  787.         LPCWSTR     szFile) = 0;            // Path for save.
  788.  
  789.  
  790. //*****************************************************************************
  791. // After a successful open, this function will return the size of the in-memory
  792. // database being used.  This is meant to be used by code that has opened a
  793. // shared memory database and needs the exact size to init the system.
  794. //*****************************************************************************
  795.     virtual HRESULT STDMETHODCALLTYPE GetDBSize( // Return code.
  796.         ULONG        *pcbSize) = 0;            // Return size on success.
  797.  
  798.  
  799. //*****************************************************************************
  800. // Call this method only after calling LightWeightClose.  This method will try
  801. // to reaquire the shared view of a database that was given on the call to
  802. // OpenComponentLibrarySharedEx.  If the data is no longer available, then an
  803. // error will result and no data is valid.    If the memory cannot be loaded into
  804. // exactly the same address range as on the open, CLDB_E_RELOCATED will be
  805. // returned.  In either of these cases, the only valid operation is to free
  806. // this instant of the database and redo the OpenComponentLibrarySharedEx.    There
  807. // is no automatic relocation scheme in the engine.
  808. //*****************************************************************************
  809.     virtual HRESULT STDMETHODCALLTYPE LightWeightOpen() = 0;
  810.  
  811.  
  812. //*****************************************************************************
  813. // This method will close any resources related to the file or shared memory
  814. // which were allocated on the OpenComponentLibrary*Ex call.  No other memory
  815. // or resources are freed.    The intent is solely to free lock handles on the
  816. // disk allowing another process to get in and change the data.  The shared
  817. // view of the file can be reopened by calling LightWeightOpen.
  818. //*****************************************************************************
  819.     virtual HRESULT STDMETHODCALLTYPE LightWeightClose() = 0;
  820.  
  821.  
  822.  
  823. //*****************************************************************************
  824. //
  825. //********** Misc.
  826. //
  827. //*****************************************************************************
  828.  
  829.     virtual HRESULT STDMETHODCALLTYPE NewOid(
  830.         OID *poid) = 0;
  831.  
  832. //*****************************************************************************
  833. // Return the current total number of objects allocated.  This is essentially
  834. // the highest OID value allocated in the system.  It does not look for deleted
  835. // items, so the count is approximate.
  836. //*****************************************************************************
  837.     virtual HRESULT STDMETHODCALLTYPE GetObjectCount(
  838.         ULONG        *piCount) = 0;
  839.  
  840. //*****************************************************************************
  841. // Allow the user to create a stream that is independent of the database.
  842. //*****************************************************************************
  843.     virtual HRESULT STDMETHODCALLTYPE OpenSection(
  844.         LPCWSTR     szName,                 // Name of the stream.
  845.         DWORD        dwFlags,                // Open flags.
  846.         REFIID        riid,                    // Interface to the stream.
  847.         IUnknown    **ppUnk) = 0;            // Put the interface here.
  848.  
  849. //*****************************************************************************
  850. // Allow the user to query write state.
  851. //*****************************************************************************
  852.     virtual HRESULT STDMETHODCALLTYPE GetOpenFlags(
  853.         DWORD        *pdwFlags) = 0;
  854.  
  855. //*****************************************************************************
  856. // Allow the user to provide a custom handler.  The purpose of the handler
  857. //  may be determined dynamically.  Initially, it will be for save-time 
  858. //  callback notification to the caller.
  859. //*****************************************************************************
  860.     virtual HRESULT STDMETHODCALLTYPE SetHandler(
  861.         IUnknown    *pHandler) = 0;            // The handler.
  862.  
  863.  
  864.  
  865. };
  866.  
  867.  
  868.  
  869. //*****************************************************************************
  870. // This is a light weight interface that allows an ICR client to get at the
  871. // meta data for a schema.    One can also retrieve this information using the
  872. // format OLE DB interfaces, such as IDBSchemaRowset.
  873. //*****************************************************************************
  874. interface IComponentRecordsSchema : public IUnknown
  875. {
  876.  
  877. //*****************************************************************************
  878. // Lookup the given table and return its table definition information in
  879. // the given struct.
  880. //*****************************************************************************
  881.     virtual HRESULT GetTableDefinition(     // Return code.
  882.         TABLEID     TableID,                // Return ID on successful open.
  883.         ICRSCHEMA_TABLE *pTableDef) = 0;    // Return table definition data.
  884.  
  885. //*****************************************************************************
  886. // Lookup the list of columns for the given table and return description of
  887. // each of them.  If GetType is ICRCOLUMN_GET_ALL, then this function will
  888. // return the data for each column in ascending order for the table in the
  889. // corresponding rgColumns element.  If it is ICRCOLUMN_GET_BYORDINAL, then
  890. // the caller has initialized the Ordianl field of the column structure to
  891. // indicate which columns data is to be retrieved.    The latter allows for ad-hoc
  892. // retrieval of column definitions.
  893. //*****************************************************************************
  894.     virtual HRESULT GetColumnDefinitions(    // Return code.
  895.         ICRCOLUMN_GET GetType,                // How to retrieve the columns.
  896.         TABLEID     TableID,                // Return ID on successful open.
  897.         ICRSCHEMA_COLUMN rgColumns[],        // Return array of columns.
  898.         int         ColCount) = 0;            // Size of the rgColumns array, which
  899.                                             //    should always match count from GetTableDefinition.
  900.  
  901. //*****************************************************************************
  902. // Return the description of the given index into the structure.  See the
  903. // ICRSCHEMA_INDEX structure definition for more information.
  904. //*****************************************************************************
  905.     virtual HRESULT GetIndexDefinition(     // Return code.
  906.         TABLEID     TableID,                // Return ID on successful open.
  907.         LPCWSTR     szIndex,                // Name of the index to retrieve.
  908.         ICRSCHEMA_INDEX *pIndex) = 0;        // Return index description here.
  909.                                             //    should always match count from GetTableDefinition.
  910.  
  911. //*****************************************************************************
  912. // Return the description of the given index into the structure.  See the
  913. // ICRSCHEMA_INDEX structure definition for more information.
  914. //*****************************************************************************
  915.     virtual HRESULT GetIndexDefinitionByNum( // Return code.
  916.         TABLEID     TableID,                // Return ID on successful open.
  917.         int         IndexNum,                // 0 based index to return.
  918.         ICRSCHEMA_INDEX *pIndex) = 0;        // Return index description here.
  919. };
  920.  
  921.  
  922. #if 0 // left to show user section interface example
  923. //*****************************************************************************
  924. // Interface definition of a user section for Call Signatures.
  925. //*****************************************************************************
  926. struct _COR_CALLDESCR;
  927. interface ICallDescrSection : public IUnknown
  928. {
  929.     virtual HRESULT STDMETHODCALLTYPE InsertCallDescr(
  930.         ULONG        ulDescr,                // Index of Descr.
  931.         ULONG        ulGroup,                // Which group is Descr in?
  932.         ULONG        cDescr,                    // Count of descrs to insert.
  933.         _COR_CALLDESCR  **ppDescr) = 0;        // Put pointer to first one here.
  934.  
  935.     virtual HRESULT STDMETHODCALLTYPE AppendCallDescr(
  936.         ULONG        ulGroup,                // Which group is Descr in?
  937.         ULONG        *pulDescr,                // Put relative index of first one here.
  938.         _COR_CALLDESCR  **ppDescr) = 0;        // Put pointer to first one here.
  939.  
  940.     virtual HRESULT STDMETHODCALLTYPE GetCallDescr(
  941.         ULONG        ulDescr,                // Index of Descr.
  942.         ULONG        ulGroup,                // Which group is Descr in?
  943.         _COR_CALLDESCR  **ppDescr) = 0;        // Put pointer here.
  944.  
  945.     virtual HRESULT STDMETHODCALLTYPE GetCallDescrGroups(
  946.         ULONG        *pcGroups,                // How many groups?
  947.         ULONG        **pprcGroup) = 0;        // Count in each group.
  948.  
  949.     virtual HRESULT STDMETHODCALLTYPE AddCallSig(
  950.         const void  *pVal,                  // The value to store.
  951.         ULONG       iLen,                   // Count of bytes in signature.
  952.         ULONG       *piOffset) = 0;         // The offset of the new item.
  953.  
  954.     virtual HRESULT STDMETHODCALLTYPE GetCallSig(
  955.         ULONG       iOffset,                // Offset of the item to get.
  956.         const void  **ppVal,                // Put pointer to Signature here.
  957.         ULONG       *piLen) = 0;            // Put length of signature here.
  958.  
  959.     virtual HRESULT STDMETHODCALLTYPE GetCallSigBuf(
  960.         const void  **ppVal) = 0;           // Put pointer to Signatures here.
  961. };
  962. #endif
  963. //*****************************************************************************
  964. // These interfaces provide a thread safe version of the ICR interfaces.  The
  965. // v-table is exactly the same as the not TS versions.    Calls through the 
  966. // TS interface will serialize calls as required.  To get the TS version,
  967. // simply do a QueryInterface on the ICR pointer returned from the open/create
  968. // function.
  969. //*****************************************************************************
  970. typedef IComponentRecordsSchema ITSComponentRecordsSchema;
  971. typedef IComponentRecords ITSComponentRecords;
  972.  
  973.  
  974.  
  975. // Internal versions of the load functions.
  976.  
  977. extern "C" {
  978.  
  979. HRESULT STDMETHODCALLTYPE CreateComponentLibraryEx(
  980.     LPCWSTR szName,
  981.     long fFlags,
  982.     IComponentRecords **ppIComponentRecords);
  983.  
  984. HRESULT STDMETHODCALLTYPE OpenComponentLibraryEx(
  985.     LPCWSTR szName,
  986.     long fFlags,
  987.     IComponentRecords **ppIComponentRecords);
  988.  
  989.  
  990. //*****************************************************************************
  991. // This version of open will open the component library allows a shared copy
  992. // of the database to be used.    A shared copy reduces overall overhead on the
  993. // system by keeping just one view of the data which can be efficiently shared
  994. // into other processes.
  995. //
  996. // CREATING THE INITIAL VIEW:
  997. //    To do the initial open, pass the name of the file and the DBPROP_TMODEF_SMEMCREATE
  998. //    flag.  This will open the data file on disk and create a file mapping with
  999. //    the name contained in szSharedMemory.
  1000. //
  1001. // OPENING SECONDARY VIEWS:
  1002. //    To open a shared view already in memory, pass the DBPROP_TMODEF_SMEMOPEN
  1003. //    flag.  The view must already exist in memory as a shared object.  If not
  1004. //    found, an error will occur.
  1005. //
  1006. // LIGHTWEIGHT CLOSE:
  1007. //    A secondary view can be closed by calling LightWeightClose which will free
  1008. //    the shared memory handle but leave everything else intact.    Then the
  1009. //    database can be "rebound" to the shared memory by calling the
  1010. //    LightWeightOpen method.  See these methods in the ICR docs for details.
  1011. //*****************************************************************************
  1012. HRESULT STDMETHODCALLTYPE OpenComponentLibrarySharedEx(
  1013.     LPCWSTR     szName,                 // Name of file on create, NULL on open.
  1014.     LPCWSTR     szSharedMemory,         // Name of shared memory.
  1015.     ULONG        cbSize,                 // Size of shared memory, 0 on create.
  1016.     LPSECURITY_ATTRIBUTES pAttributes,    // Security token.
  1017.     long        fFlags,                 // Open modes, must be read only.
  1018.     IComponentRecords **ppIComponentRecords); // Return database on success.
  1019.  
  1020.  
  1021. HRESULT STDMETHODCALLTYPE OpenComponentLibraryOnStreamEx(
  1022.     IStream *pIStream,
  1023.     long fFlags,
  1024.     IComponentRecords **ppIComponentRecords);
  1025.  
  1026.  
  1027. HRESULT STDMETHODCALLTYPE OpenComponentLibraryOnMemEx(
  1028.     ULONG cbData,
  1029.     LPCVOID pbData,
  1030.     IComponentRecords **ppIComponentRecords);
  1031.  
  1032.  
  1033. } // extern "C"
  1034.