home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / dotNETSDK / SETUP.EXE / netfxsd1.cab / FL_ICmpRecs_h________.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Encoding:
Text File  |  2001-07-24  |  47.2 KB  |  1,037 lines

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