WabUtil.pas 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  1. {******************************************************************}
  2. { }
  3. { Borland Delphi Runtime Library }
  4. { Windows Address Book (WAB) functions interface unit }
  5. { }
  6. { Portions created by Microsoft are }
  7. { Copyright (C) 1995-2000 Microsoft Corporation. }
  8. { All Rights Reserved. }
  9. { }
  10. { The original file is: wabutil.h, released 31 Jan 2000. }
  11. { The original Pascal code is: WabUtil.pas, released 31 Mar 2000. }
  12. { The initial developer of the Pascal code is Petr Vones }
  13. { (petr.v@mujmail.cz). }
  14. { }
  15. { Portions created by Petr Vones are }
  16. { Copyright (C) 2000 Petr Vones }
  17. { }
  18. { Obtained through: }
  19. { }
  20. { Joint Endeavour of Delphi Innovators (Project JEDI) }
  21. { }
  22. { You may retrieve the latest version of this file at the Project }
  23. { JEDI home page, located at http://delphi-jedi.org }
  24. { }
  25. { The contents of this file are used with permission, subject to }
  26. { the Mozilla Public License Version 1.1 (the "License"); you may }
  27. { not use this file except in compliance with the License. You may }
  28. { obtain a copy of the License at }
  29. { http://www.mozilla.org/MPL/MPL-1.1.html }
  30. { }
  31. { Software distributed under the License is distributed on an }
  32. { "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
  33. { implied. See the License for the specific language governing }
  34. { rights and limitations under the License. }
  35. { }
  36. {******************************************************************}
  37. unit WabUtil;
  38. interface
  39. uses
  40. Windows, ActiveX, WabDefs, WabMem;
  41. {$I WAB.INC}
  42. {$ALIGN ON}
  43. {$MINENUMSIZE 4}
  44. { IMAPITable in memory }
  45. { ITableData Interface ---------------------------------------------------- }
  46. type
  47. ITableData = interface;
  48. PCallRelease = ^TCallRelease;
  49. CALLERRELEASE = procedure (ulCallerData: ULONG; lpTblData: ITableData;
  50. lpVue: IMAPITable); stdcall;
  51. TCallRelease = CALLERRELEASE;
  52. ITableData = interface(IUnknown)
  53. function HrGetView(lpSSortOrderSet: PSSortOrderSet; lpfCallerRelease: PCallRelease;
  54. ulCallerData: ULONG; out lppMAPITable: IMAPITable): HResult; stdcall;
  55. function HrModifyRow(lpSRow: PSRow): HResult; stdcall;
  56. function HrDeleteRow(lpSPropValue: PSPropValue): HResult; stdcall;
  57. function HrQueryRow(lpsPropValue: PSPropValue; var lppSRow: PSRow;
  58. lpuliRow: PULONG): HResult; stdcall;
  59. function HrEnumRow(ulRowNumber: ULONG; var lppSRow: PSRow): HResult; stdcall;
  60. function HrNotify(ulFlags, cValues: ULONG; lpSPropValue: PSPropValue): HResult; stdcall;
  61. function HrInsertRow(uliRow: ULONG; lpSRow: PSRow): HResult; stdcall;
  62. function HrModifyRows(ulFlags: ULONG; lpSRowSet: PSRowSet): HResult; stdcall;
  63. function HrDeleteRows(ulFlags: ULONG; lprowsetToDelete: PSRowSet;
  64. var cRowsDeleted: ULONG): HResult; stdcall;
  65. end;
  66. {$EXTERNALSYM ITableData}
  67. { Entry Point for in memory ITable }
  68. {* CreateTable()
  69. * Creates the internal memory structures and object handle
  70. * to bring a new table into existence.
  71. *
  72. * lpInterface
  73. * Interface ID of the TableData object (IID_IMAPITableData)
  74. *
  75. * lpAllocateBuffer, lpAllocateMore, and lpFreeBuffer
  76. * Function addresses are provided by the caller so that
  77. * this DLL allocates/frees memory appropriately.
  78. * lpvReserved
  79. * Reserved. Should be NULL.
  80. * ulTableType
  81. * TBLTYPE_DYNAMIC, etc. Visible to the calling application
  82. * as part of the GetStatus return data on its views
  83. * ulPropTagIndexColumn
  84. * Index column for use when changing the data
  85. * lpSPropTagArrayColumns
  86. * Column proptags for the minimum set of columns in the table
  87. * lppTableData
  88. * Address of the pointer which will receive the TableData object
  89. *}
  90. function CreateTable(lpInterface: PCIID; lpAllocateBuffer: PAllocateBuffer;
  91. lpAllocateMore: PAllocateMore; lpFreeBuffer: PFreeBuffer; lpvReserved: Pointer;
  92. ulTableType, ulPropTagIndexColumn: ULONG; lpSPropTagArrayColumns: PSPropTagArray;
  93. out lppTableData: ITableData): SCODE; stdcall;
  94. {$EXTERNALSYM CreateTable}
  95. {* HrGetView()
  96. * This function obtains a new view on the underlying data
  97. * which supports the IMAPITable interface. All rows and columns
  98. * of the underlying table data are initially visible
  99. * lpSSortOrderSet
  100. * if specified, results in the view being sorted
  101. * lpfCallerRelease
  102. * pointer to a routine to be called when the view is released, or
  103. * NULL.
  104. * ulCallerData
  105. * arbitrary data the caller wants saved with this view and returned in
  106. * the Release callback.
  107. *}
  108. {* HrModifyRows()
  109. * Add or modify a set of rows in the table data
  110. * ulFlags
  111. * Must be zero
  112. * lpSRowSet
  113. * Each row in the row set contains all the properties for one row
  114. * in the table. One of the properties must be the index column. Any
  115. * row in the table with the same value for its index column is
  116. * replaced, or if there is no current row with that value the
  117. * row is added.
  118. * Each row in LPSRowSet MUST have a unique Index column!
  119. * If any views are open, the view is updated as well.
  120. * The properties do not have to be in the same order as the
  121. * columns in the current table
  122. *}
  123. {* HrModifyRow()
  124. * Add or modify one row in the table
  125. * lpSRow
  126. * This row contains all the properties for one row in the table.
  127. * One of the properties must be the index column. Any row in
  128. * the table with the same value for its index column is
  129. * replaced, or if there is no current row with that value the
  130. * row is added
  131. * If any views are open, the view is updated as well.
  132. * The properties do not have to be in the same order as the
  133. * columns in the current table
  134. *}
  135. {* HrDeleteRows()
  136. * Delete a row in the table.
  137. * ulFlags
  138. * TAD_ALL_ROWS - Causes all rows in the table to be deleted
  139. * lpSRowSet is ignored in this case.
  140. * lpSRowSet
  141. * Each row in the row set contains all the properties for one row
  142. * in the table. One of the properties must be the index column. Any
  143. * row in the table with the same value for its index column is
  144. * deleted.
  145. * Each row in LPSRowSet MUST have a unique Index column!
  146. * If any views are open, the view is updated as well.
  147. * The properties do not have to be in the same order as the
  148. * columns in the current table
  149. *}
  150. const
  151. TAD_ALL_ROWS = 1;
  152. {$EXTERNALSYM TAD_ALL_ROWS}
  153. {* HrDeleteRow()
  154. * Delete a row in the table.
  155. * lpSPropValue
  156. * This property value specifies the row which has this value
  157. * for its index column
  158. *}
  159. {* HrQueryRow()
  160. * Returns the values of a specified row in the table
  161. * lpSPropValue
  162. * This property value specifies the row which has this value
  163. * for its index column
  164. * lppSRow
  165. * Address of where to return a pointer to an SRow
  166. * lpuliRow
  167. * Address of where to return the row number. This can be NULL
  168. * if the row number is not required.
  169. *
  170. *}
  171. {* HrEnumRow()
  172. * Returns the values of a specific (numbered) row in the table
  173. * ulRowNumber
  174. * Indicates row number 0 to n-1
  175. * lppSRow
  176. * Address of where to return a pointer to a SRow
  177. *}
  178. {* HrInsertRow()
  179. * Inserts a row into the table.
  180. * uliRow
  181. * The row number before which this row will be inserted into the table.
  182. * Row numbers can be from 0 to n where o to n-1 result in row insertion
  183. * a row number of n results in the row being appended to the table.
  184. * lpSRow
  185. * This row contains all the properties for one row in the table.
  186. * One of the properties must be the index column. Any row in
  187. * the table with the same value for its index column is
  188. * replaced, or if there is no current row with that value the
  189. * row is added
  190. * If any views are open, the view is updated as well.
  191. * The properties do not have to be in the same order as the
  192. * columns in the current table
  193. *}
  194. { IMAPIProp in memory }
  195. { IPropData Interface ---------------------------------------------------- }
  196. type
  197. IPropData = interface(IMAPIProp)
  198. function HrSetObjAccess(ulAccess: ULONG): HResult; stdcall;
  199. function HrSetPropAccess(lpPropTagArray: PSPropTagArray; rgulAccess: PULONG): HResult; stdcall;
  200. function HrGetPropAccess(lppPropTagArray: PSPropTagArray;
  201. var lprgulAccess: PULONG): HResult; stdcall;
  202. function HrAddObjProps(lppPropTagArray: PSPropTagArray;
  203. lprgulAccess: PSPropProblemArray): HResult; stdcall;
  204. end;
  205. {$EXTERNALSYM IPropData}
  206. { Entry Point for in memory IMAPIProp }
  207. {* CreateIProp()
  208. * Creates the internal memory structures and object handle
  209. * to bring a new property interface into existance.
  210. *
  211. * lpInterface
  212. * Interface ID of the TableData object (IID_IMAPIPropData)
  213. *
  214. * lpAllocateBuffer, lpAllocateMore, and lpFreeBuffer
  215. * Function addresses are provided by the caller so that
  216. * this DLL allocates/frees memory appropriately.
  217. * lppPropData
  218. * Address of the pointer which will receive the IPropData object
  219. * lpvReserved
  220. * Reserved. Should be NULL.
  221. *}
  222. type
  223. TWABCreateIProp = function(lpInterface: PCIID; lpAllocateBuffer: PAllocateBuffer;
  224. lpAllocateMore: PAllocateMore; lpFreeBuffer: PFreeBuffer; lpvReserved: Pointer;
  225. out lppPropData: IPropData): SCODE; stdcall;
  226. { Defines for prop/obj access }
  227. const
  228. IPROP_READONLY = ULONG($00000001);
  229. {$EXTERNALSYM IPROP_READONLY}
  230. IPROP_READWRITE = ULONG($00000002);
  231. {$EXTERNALSYM IPROP_READWRITE}
  232. IPROP_CLEAN = ULONG($00010000);
  233. {$EXTERNALSYM IPROP_CLEAN}
  234. IPROP_DIRTY = ULONG($00020000);
  235. {$EXTERNALSYM IPROP_DIRTY}
  236. {*
  237. - HrSetPropAccess
  238. -
  239. * Sets access right attributes on a per-property basis. By default,
  240. * all properties are read/write.
  241. *}
  242. {*
  243. - HrSetObjAccess
  244. -
  245. * Sets access rights for the object itself. By default, the object has
  246. * read/write access.
  247. *}
  248. { Idle time scheduler }
  249. {*
  250. * PRI
  251. *
  252. * Priority of an idle task.
  253. * The idle engine sorts tasks by priority, and the one with the higher
  254. * value runs first. Within a priority level, the functions are called
  255. * round-robin.
  256. *}
  257. PRILOWEST = -32768;
  258. {$EXTERNALSYM PRILOWEST}
  259. PRIHIGHEST = 32767;
  260. {$EXTERNALSYM PRIHIGHEST}
  261. PRIUSER = 0;
  262. {$EXTERNALSYM PRIUSER}
  263. {*
  264. * IRO
  265. *
  266. * Idle routine options. This is a combined bit mask consisting of
  267. * individual firo's. Listed below are the possible bit flags.
  268. *
  269. * FIROWAIT and FIROINTERVAL are mutually exclusive.
  270. * If neither of the flags are specified, the default action
  271. * is to ignore the time parameter of the idle function and
  272. * call it as often as possible if firoPerBlock is not set;
  273. * otherwise call it one time only during the idle block
  274. * once the time constraint has been set. FIROINTERVAL
  275. * is also incompatible with FIROPERBLOCK.
  276. *
  277. * FIROWAIT - time given is minimum idle time before calling
  278. * for the first time in the block of idle time,
  279. * afterwhich call as often as possible.
  280. * FIROINTERVAL - time given is minimum interval between each
  281. * successive call
  282. * FIROPERBLOCK - called only once per contiguous block of idle
  283. * time
  284. * FIRODISABLED - initially disabled when registered, the
  285. * default is to enable the function when registered.
  286. * FIROONCEONLY - called only one time by the scheduler and then
  287. * deregistered automatically.
  288. *}
  289. IRONULL = Word($0000);
  290. {$EXTERNALSYM IRONULL}
  291. FIROWAIT = Word($0001);
  292. {$EXTERNALSYM FIROWAIT}
  293. FIROINTERVAL = Word($0002);
  294. {$EXTERNALSYM FIROINTERVAL}
  295. FIROPERBLOCK = Word($0004);
  296. {$EXTERNALSYM FIROPERBLOCK}
  297. FIRODISABLED = Word($0020);
  298. {$EXTERNALSYM FIRODISABLED}
  299. FIROONCEONLY = Word($0040);
  300. {$EXTERNALSYM FIROONCEONLY}
  301. {*
  302. * IRC
  303. *
  304. * Idle routine change options. This is a combined bit mask consisting
  305. * of individual firc's; each one identifies an aspect of the idle task
  306. * that can be changed.
  307. *
  308. *}
  309. IRCNULL = Word($0000);
  310. {$EXTERNALSYM IRCNULL}
  311. FIRCPFN = Word($0001); // change function pointer
  312. {$EXTERNALSYM FIRCPFN}
  313. FIRCPV = Word($0002); // change parameter block
  314. {$EXTERNALSYM FIRCPV}
  315. FIRCPRI = Word($0004); // change priority
  316. {$EXTERNALSYM FIRCPRI}
  317. FIRCCSEC = Word($0008); // change time
  318. {$EXTERNALSYM FIRCCSEC}
  319. FIRCIRO = Word($0010); // change routine options
  320. {$EXTERNALSYM FIRCIRO}
  321. {*
  322. * Type definition for idle functions. An idle function takes one
  323. * parameter, an PV, and returns a BOOL value.
  324. *}
  325. type
  326. PFnIdle = ^TFnIdle;
  327. FNIDLE = function (lpvContext: Pointer): BOOL; stdcall;
  328. {$EXTERNALSYM FNIDLE}
  329. TFnIdle = FNIDLE;
  330. {*
  331. * FTG
  332. *
  333. * Function Tag. Used to identify a registered idle function.
  334. *
  335. *}
  336. FTG = Pointer;
  337. {$EXTERNALSYM FTG}
  338. const
  339. FTGNULL = nil;
  340. {$EXTERNALSYM FTGNULL}
  341. {*
  342. - MAPIInitIdle/MAPIDeinitIdle
  343. -
  344. * Purpose:
  345. * Initialises the idle engine
  346. * If the initialisation succeded, returns 0, else returns -1
  347. *
  348. * Arguments:
  349. * lpvReserved Reserved, must be NULL.
  350. *}
  351. function MAPIInitIdle(lpvReserved: Pointer): LongInt; stdcall;
  352. {$EXTERNALSYM MAPIInitIdle}
  353. procedure MAPIDeinitIdle; stdcall;
  354. {$EXTERNALSYM MAPIDeinitIdle}
  355. {*
  356. * FtgRegisterIdleRoutine
  357. *
  358. * Registers the function pfn of type PFNIDLE, i.e., (BOOL (*)(LPVOID))
  359. * as an idle function.
  360. *
  361. * The idle function will be called with the parameter pv by the
  362. * idle engine. The function has initial priority priIdle,
  363. * associated time csecIdle, and options iroIdle.
  364. *}
  365. function FtgRegisterIdleRoutine(lpfnIdle: PFnIdle; lpvIdleParam: Pointer;
  366. priIdle: SmallInt; csecIdle: ULONG; iroIdle: Word): FTG; stdcall;
  367. {$EXTERNALSYM FtgRegisterIdleRoutine}
  368. {*
  369. * DeregisterIdleRoutine
  370. *
  371. * Removes the given routine from the list of idle routines.
  372. * The routine will not be called again. It is the responsibility
  373. * of the caller to clean up any data structures pointed to by the
  374. * pvIdleParam parameter; this routine does not free the block.
  375. *}
  376. procedure DeregisterIdleRoutine(ftg: FTG); stdcall;
  377. {$EXTERNALSYM DeregisterIdleRoutine}
  378. {*
  379. * EnableIdleRoutine
  380. *
  381. * Enables or disables an idle routine.
  382. *}
  383. procedure EnableIdleRoutine(ftg: FTG; fEnable: BOOL); stdcall;
  384. {$EXTERNALSYM EnableIdleRoutine}
  385. {*
  386. * ChangeIdleRoutine
  387. *
  388. * Changes some or all of the characteristics of the given idle
  389. * function. The changes to make are indicated with flags in the
  390. * ircIdle parameter.
  391. *}
  392. procedure ChangeIdleRoutine(ftg: FTG; lpfnIdle: PFnIdle; lpvIdleParam: Pointer;
  393. priIdle: SmallInt; csecIdle: ULONG; iroIdle: Word; ircIdle: Word); stdcall;
  394. {$EXTERNALSYM ChangeIdleRoutine}
  395. { IMalloc Utilities }
  396. function MAPIGetDefaultMalloc: IMalloc; stdcall;
  397. {$EXTERNALSYM MAPIGetDefaultMalloc}
  398. { StreamOnFile (SOF) }
  399. {*
  400. * Methods and #define's for implementing an OLE 2.0 storage stream
  401. * (as defined in the OLE 2.0 specs) on top of a system file.
  402. *}
  403. const
  404. SOF_UNIQUEFILENAME = ULONG($80000000);
  405. {$EXTERNALSYM SOF_UNIQUEFILENAME}
  406. function OpenStreamOnFile(lpAllocateBuffer: PAllocateBuffer;
  407. lpFreeBuffer: PFreeBuffer; ulFlags: ULONG; lpszFileName, lpszPrefix: LPTSTR;
  408. out lppStream: IStream): HResult; stdcall;
  409. {$EXTERNALSYM OpenStreamOnFile}
  410. { Property interface utilities }
  411. {*
  412. * Copies a single SPropValue from Src to Dest. Handles all the various
  413. * types of properties and will link its allocations given the master
  414. * allocation object and an allocate more function.
  415. *}
  416. function PropCopyMore(lpSPropValueDest, lpSPropValueSrc: PSPropValue;
  417. lpfAllocMore: PAllocateMore; lpvObject: Pointer): SCODE; stdcall;
  418. {$EXTERNALSYM PropCopyMore}
  419. {*
  420. * Returns the size in bytes of structure at lpSPropValue, including the
  421. * Value.
  422. *}
  423. function UlPropSize(lpSPropValue: PSPropValue): ULONG; stdcall;
  424. {$EXTERNALSYM UlPropSize}
  425. function FEqualNames(lpName1, lpName2: PMapiNameID): BOOL; stdcall;
  426. {$EXTERNALSYM FEqualNames}
  427. //procedure GetInstance(lpPropMv, lpPropSv: PSPropValue; uliInst: ULONG); stdcall;
  428. //{$EXTERNALSYM GetInstance}
  429. function FPropContainsProp(const lpSPropValueDst, lpSPropValueSrc: TSPropValue;
  430. ulFuzzyLevel: ULONG): BOOL; stdcall;
  431. {$EXTERNALSYM FPropContainsProp}
  432. function FPropCompareProp(const lpSPropValue1: TSPropValue; ulRelOp: ULONG;
  433. const lpSPropValue2: TSPropValue): BOOL; stdcall;
  434. {$EXTERNALSYM FPropCompareProp}
  435. function LPropCompareProp(const lpSPropValueA, lpSPropValueB: TSPropValue): LongInt; stdcall;
  436. {$EXTERNALSYM LPropCompareProp}
  437. function HrAddColumns(lptbl: IMAPITable; lpproptagColumnsNew: PSPropTagArray;
  438. lpAllocateBuffer: PAllocateBuffer; lpFreeBuffer: PFreeBuffer): HResult; stdcall;
  439. {$EXTERNALSYM HrAddColumns}
  440. function HrAddColumnsEx(lptbl: IMAPITable; lpproptagColumnsNew: PSPropTagArray;
  441. lpAllocateBuffer: PAllocateBuffer; lpFreeBuffer: PFreeBuffer;
  442. ptaga: PSPropTagArray): HResult; stdcall;
  443. {$EXTERNALSYM HrAddColumnsEx}
  444. { Notification utilities }
  445. {*
  446. * Function that creates an advise sink object given a notification
  447. * callback function and context.
  448. *}
  449. procedure HrAllocAdviseSink(lpfnCallback: TNotifyCallback; lpvContext: Pointer;
  450. out lppAdviseSink: IMAPIAdviseSink);
  451. {$EXTERNALSYM HrAllocAdviseSink}
  452. {*
  453. * Wraps an existing advise sink with another one which guarantees
  454. * that the original advise sink will be called in the thread on
  455. * which it was created.
  456. *}
  457. procedure HrThisThreadAdviseSink(lpAdviseSink: IMAPIAdviseSink;
  458. out lppAdviseSink: IMAPIAdviseSink);
  459. {$EXTERNALSYM HrThisThreadAdviseSink}
  460. {*
  461. * Allows a client and/or provider to force notifications
  462. * which are currently queued in the MAPI notification engine
  463. * to be dispatched without doing a message dispatch.
  464. *}
  465. function HrDispatchNotifications(ulFlags: ULONG): HResult; stdcall;
  466. {$EXTERNALSYM HrDispatchNotifications}
  467. { Service Provider Utilities }
  468. {*
  469. * Structures and utility function for building a display table
  470. * from resources.
  471. *}
  472. type
  473. PDtCtl = ^TDtCtl;
  474. DTCTL = record
  475. ulCtlType: ULONG; // DTCT_LABEL, etc.
  476. ulCtlFlags: ULONG; // DT_REQUIRED, etc.
  477. lpbNotif: Pointer; // pointer to notification data
  478. cbNotif: ULONG; // count of bytes of notification data
  479. lpszFilter: LPTSTR; // character filter for edit/combobox
  480. ulItemID: ULONG; // to validate parallel dlg template entry
  481. case Integer of
  482. -1: (lpv: Pointer;); // Initialize this to avoid warnings
  483. DTCT_LABEL: (lplabel: PDTblLabel;);
  484. DTCT_EDIT: (lpedit: PDTblEdit;);
  485. DTCT_LBX: (lplbx: PDTblLbx;);
  486. DTCT_COMBOBOX: (lpcombobox: PDTblComboBox;);
  487. DTCT_DDLBX: (lpddlbx: PDTblDDLbx;);
  488. DTCT_CHECKBOX: (lpcheckbox: PDTblCheckBox;);
  489. DTCT_GROUPBOX: (lpgroupbox: PDTblGroupBox;);
  490. DTCT_BUTTON: (lpbutton: PDTblButton;);
  491. DTCT_RADIOBUTTON: (lpradiobutton: PDTblRadioButton;);
  492. DTCT_MVLISTBOX: (lpmvlbx: PDTblMvListBox;);
  493. DTCT_MVDDLBX: (lpmvddlbx: PDTblMvDDLbx;);
  494. DTCT_PAGE: (lppage: PDTblPage;);
  495. end;
  496. {$EXTERNALSYM DTCTL}
  497. TDtCtl = DTCTL;
  498. PDtPage = ^TDtPage;
  499. DTPAGE = record
  500. cctl: ULONG;
  501. lpszResourceName: LPTSTR; // as usual, may be an integer ID
  502. case Integer of
  503. 1: (lpszComponent: LPTSTR;);
  504. 2: (ulItemID: ULONG;);
  505. end;
  506. {$EXTERNALSYM DTPAGE}
  507. TDtPage = DTPAGE;
  508. procedure BuildDisplayTable(lpAllocateBuffer: PAllocateBuffer;
  509. lpAllocateMore: PAllocateMore; lpFreeBuffer: PFreeBuffer; lpMalloc: IMAlloc;
  510. hInstance: Cardinal; cPages: UINT; lpPage: PDtPage; ulFlags: ULONG;
  511. out lppTable: IMAPITable; lppTblData: ITableData);
  512. {$EXTERNALSYM BuildDisplayTable}
  513. { MAPI structure validation/copy utilities }
  514. {*
  515. * Validate, copy, and adjust pointers in MAPI structures:
  516. * notification
  517. * property value array
  518. * option data
  519. *}
  520. function ScCountNotifications(cNotifications: Integer;
  521. lpNotifications: PNotification; var lpcb: ULONG): SCODE; stdcall;
  522. {$EXTERNALSYM ScCountNotifications}
  523. function ScCopyNotifications(cNotifications: Integer;
  524. lpNotifications: PNotification; lpvDst: Pointer; var lpcb: ULONG): SCODE; stdcall;
  525. {$EXTERNALSYM ScCopyNotifications}
  526. function ScRelocNotifications(cNotifications: Integer;
  527. lpNotifications: PNotification; lpvBaseOld, lpvBaseNew: Pointer;
  528. var lpcb: ULONG): SCODE; stdcall;
  529. {$EXTERNALSYM ScRelocNotifications}
  530. function ScCountProps(cValues: Integer; lpPropArray: PSPropValue;
  531. var lpcb: ULONG): SCODE; stdcall;
  532. {$EXTERNALSYM ScCountProps}
  533. function LpValFindProp(ulPropTag, cValues: ULONG; lpPropArray: PSPropValue): PSPropValue; stdcall;
  534. {$EXTERNALSYM LpValFindProp}
  535. function ScCopyProps(cValues: Integer; lpPropArray: PSPropValue; lpvDst: Pointer;
  536. var lpcb: ULONG): SCODE; stdcall;
  537. {$EXTERNALSYM ScCopyProps}
  538. function ScRelocProps(cValues: Integer; lpPropArray: PSPropValue;
  539. lpvBaseOld, lpvBaseNew: Pointer; var lpcb: ULONG): SCODE; stdcall;
  540. {$EXTERNALSYM ScRelocProps}
  541. function ScDupPropset(cValues: Integer; lpPropArray: PSPropValue;
  542. lpAllocateBuffer: PAllocateBuffer; var lppPropArray: PSPropValue): SCODE; stdcall;
  543. {$EXTERNALSYM ScDupPropset}
  544. { General utility functions }
  545. { Related to the OLE Component object model }
  546. function UlAddRef(lpunk: IUnknown): ULONG;
  547. {$EXTERNALSYM UlAddRef}
  548. function UlRelease(lpunk: IUnknown): ULONG;
  549. {$EXTERNALSYM UlRelease}
  550. { Related to the MAPI interface }
  551. procedure HrGetOneProp(lpMapiProp: IMAPIProp; ulPropTag: ULONG;
  552. var lppProp: PSPropValue); stdcall;
  553. {$EXTERNALSYM HrGetOneProp}
  554. procedure HrSetOneProp(lpMapiProp: IMAPIProp; lpProp: PSPropValue); stdcall;
  555. {$EXTERNALSYM HrSetOneProp}
  556. function FPropExists(lpMapiProp: IMAPIProp; ulPropTag: ULONG): BOOL; stdcall;
  557. {$EXTERNALSYM FPropExists}
  558. function PpropFindProp(lpPropArray: PSPropValue; cValues: ULONG;
  559. {$EXTERNALSYM PpropFindProp}
  560. ulPropTag: ULONG): PSPropValue; stdcall;
  561. procedure FreePadrlist(lpAdrlist: PAdrList); stdcall;
  562. {$EXTERNALSYM FreePadrlist}
  563. procedure FreeProws(lpRows: PSRowSet); stdcall;
  564. {$EXTERNALSYM FreeProws}
  565. function HrQueryAllRows(lpTable: IMAPITable; lpPropTags: PSPropTagArray;
  566. lpRestriction: PSRestriction; lpSortOrderSet: PSSortOrderSet;
  567. crowsMax: LongInt; var lppRows: PSRowSet): HResult; stdcall;
  568. {$EXTERNALSYM HrQueryAllRows}
  569. { C runtime substitutes }
  570. function SzFindCh(lpsz: LPCTSTR; ch: Byte): LPCTSTR; // strchr
  571. {$EXTERNALSYM SzFindCh}
  572. function SzFindLastCh(lpsz: LPCTSTR; ch: Byte): LPCTSTR; // strrchr
  573. {$EXTERNALSYM SzFindLastCh}
  574. function SzFindSz(lpsz, lpszKey: LPCTSTR): LPCTSTR; // strstr
  575. {$EXTERNALSYM SzFindSz}
  576. function UFromSz(lpsz: LPCTSTR): DWORD; // atoi
  577. {$EXTERNALSYM UFromSz}
  578. function ScUNCFromLocalPath(lpszLocal, lpszUNC: LPSTR; cchUNC: UINT): SCODE; stdcall;
  579. {$EXTERNALSYM ScUNCFromLocalPath}
  580. function ScLocalPathFromUNC(lpszUNC, lpszLocal: LPSTR; cchLocal: UINT): SCODE; stdcall;
  581. {$EXTERNALSYM ScLocalPathFromUNC}
  582. { 64-bit arithmetic with times }
  583. function FtAddFt(ftAddend1, ftAddend2: TFileTime): TFileTime; stdcall;
  584. {$EXTERNALSYM FtAddFt}
  585. function FtMulDwDw(ftMultiplicand, ftMultiplier: DWORD): TFileTime; stdcall;
  586. {$EXTERNALSYM FtMulDwDw}
  587. function FtMulDw(ftMultiplier: DWORD; ftMultiplicand: TFileTime): TFileTime; stdcall;
  588. {$EXTERNALSYM FtMulDw}
  589. function FtSubFt(ftMinuend, ftSubtrahend: TFileTime): TFileTime; stdcall;
  590. {$EXTERNALSYM FtSubFt}
  591. function FtNegFt(ft: TFileTime): TFileTime; stdcall;
  592. {$EXTERNALSYM FtNegFt}
  593. { Message composition }
  594. function ScCreateConversationIndex(cbParent: ULONG; lpbParent: Pointer;
  595. var lpcbConvIndex: ULONG; var lppbConvIndex: Pointer): SCODE; stdcall;
  596. {$EXTERNALSYM ScCreateConversationIndex}
  597. { Store support }
  598. procedure WrapStoreEntryID(ulFlags: ULONG; lpszDLLName: LPTSTR; cbOrigEntry: ULONG;
  599. lpOrigEntry: PEntryID; var lpcbWrappedEntry: ULONG; var lppWrappedEntry: PEntryID); stdcall;
  600. {$EXTERNALSYM WrapStoreEntryID}
  601. { RTF Sync Utilities }
  602. const
  603. RTF_SYNC_RTF_CHANGED = $00000001;
  604. {$EXTERNALSYM RTF_SYNC_RTF_CHANGED}
  605. RTF_SYNC_BODY_CHANGED = $00000002;
  606. {$EXTERNALSYM RTF_SYNC_BODY_CHANGED}
  607. function RTFSync(lpMessage: IMessage; ulFlags: ULONG; var lpfMessageUpdated: Boolean): HResult; stdcall;
  608. {$EXTERNALSYM RTFSync}
  609. { Flags for WrapCompressedRTFStream() }
  610. //****** MAPI_MODIFY ((ULONG) 0x00000001) mapidefs.h */
  611. //****** STORE_UNCOMPRESSED_RTF ((ULONG) 0x00008000) mapidefs.h */
  612. function WrapCompressedRTFStream(lpCompressedRTFStream: IStream; ulFlags: ULONG;
  613. out lpUncompressedRTFStream: IStream): HResult; stdcall;
  614. {$EXTERNALSYM WrapCompressedRTFStream}
  615. { Storage on Stream }
  616. function HrIStorageFromStream(lpUnkIn: IUnknown; lpInterface: PCIID;
  617. ulFlags: ULONG; out lppStorageOut: IStorage): HResult; stdcall;
  618. {$EXTERNALSYM HrIStorageFromStream}
  619. {*
  620. * Setup and cleanup.
  621. *
  622. * Providers never need to make these calls.
  623. *
  624. * Test applications and the like which do not call MAPIInitialize
  625. * may want to call them, so that the few utility functions which
  626. * need MAPI allocators (and do not ask for them explicitly)
  627. * will work.
  628. *}
  629. { All flags are reserved for ScInitMapiUtil. }
  630. function ScInitMapiUtil(ulFlags: ULONG): SCODE; stdcall;
  631. {$EXTERNALSYM ScInitMapiUtil}
  632. procedure DeinitMapiUtil; stdcall;
  633. {$EXTERNALSYM DeinitMapiUtil}
  634. function WabUtilLoaded: Boolean;
  635. {$IFDEF WAB_DYNAMIC_LINK_EXPLICIT}
  636. function LoadWabUtil: Boolean;
  637. function UnloadWabUtil: Boolean;
  638. {$ENDIF}
  639. var
  640. WABCreateIProp: TWABCreateIProp = nil;
  641. {$EXTERNALSYM WABCreateIProp}
  642. implementation
  643. uses
  644. WabApi, SysUtils;
  645. const
  646. mapi32 = 'mapi32.dll';
  647. function SzFindCh(lpsz: LPCTSTR; ch: Byte): LPCTSTR;
  648. begin
  649. Result := StrScan(lpsz, Char(ch));
  650. end;
  651. function SzFindLastCh(lpsz: LPCTSTR; ch: Byte): LPCTSTR;
  652. begin
  653. Result := StrRScan(lpsz, Char(ch));
  654. end;
  655. function SzFindSz(lpsz, lpszKey: LPCTSTR): LPCTSTR;
  656. begin
  657. Result := StrPos(lpsz, lpszKey);
  658. end;
  659. function UFromSz(lpsz: LPCTSTR): DWORD;
  660. begin
  661. Result := StrToIntDef(StrPas(lpsz), 0);
  662. end;
  663. var
  664. WabLibHandle: THandle = 0;
  665. function WabUtilLoaded: Boolean;
  666. begin
  667. Result := WabLibHandle <> 0;
  668. end;
  669. function UnloadWabUtil: Boolean;
  670. begin
  671. if WabUtilLoaded then
  672. begin
  673. Result := FreeLibrary(WabLibHandle);
  674. WabLibHandle := 0;
  675. @WABCreateIProp := nil;
  676. end else Result := True;
  677. end;
  678. function LoadWabUtil: Boolean;
  679. var
  680. WabDllPath: string;
  681. begin
  682. Result := WabUtilLoaded;
  683. if (not Result) and GetWabDllPath(WabDllPath) then
  684. begin
  685. WabLibHandle := LoadLibrary(PChar(WabDllPath));
  686. if WabUtilLoaded then
  687. begin
  688. WABCreateIProp := GetProcAddress(WabLibHandle, 'WABCreateIProp');
  689. Result := Assigned(WABCreateIProp);
  690. if not Result then UnloadWabUtil;
  691. end;
  692. end;
  693. end;
  694. function CreateTable; external mapi32 name 'CreateTable@36';
  695. function MAPIInitIdle; external mapi32 name 'MAPIInitIdle@4';
  696. procedure MAPIDeinitIdle; external mapi32 name 'MAPIDeinitIdle@0';
  697. function FtgRegisterIdleRoutine; external mapi32 name 'FtgRegisterIdleRoutine@20';
  698. procedure DeregisterIdleRoutine; external mapi32 name 'DeregisterIdleRoutine@4';
  699. procedure EnableIdleRoutine; external mapi32 name 'EnableIdleRoutine@8';
  700. procedure ChangeIdleRoutine; external mapi32 name 'ChangeIdleRoutine@28';
  701. function MAPIGetDefaultMalloc; external mapi32 name 'MAPIGetDefaultMalloc@0';
  702. function OpenStreamOnFile; external mapi32 name 'OpenStreamOnFile';
  703. function PropCopyMore; external mapi32 name 'PropCopyMore@16';
  704. function UlPropSize; external mapi32 name 'UlPropSize@4';
  705. function FEqualNames; external mapi32 name 'FEqualNames@8';
  706. //procedure GetInstance; external mapi32 name 'GetInstance';
  707. function FPropContainsProp; external mapi32 name 'FPropContainsProp@12';
  708. function FPropCompareProp; external mapi32 name 'FPropCompareProp@12';
  709. function LPropCompareProp; external mapi32 name 'LPropCompareProp@8';
  710. function HrAddColumns; external mapi32 name 'HrAddColumns@16';
  711. function HrAddColumnsEx; external mapi32 name 'HrAddColumnsEx@20';
  712. procedure HrAllocAdviseSink; external mapi32 name 'HrAllocAdviseSink@12';
  713. procedure HrThisThreadAdviseSink; external mapi32 name 'HrThisThreadAdviseSink@8';
  714. function HrDispatchNotifications; external mapi32 name 'HrDispatchNotifications@4';
  715. procedure BuildDisplayTable; external mapi32 name 'BuildDisplayTable@40';
  716. function ScCountNotifications; external mapi32 name 'ScCountNotifications@12';
  717. function ScCopyNotifications; external mapi32 name 'ScCopyNotifications@16';
  718. function ScRelocNotifications; external mapi32 name 'ScRelocNotifications@20';
  719. function ScCountProps; external mapi32 name 'ScCountProps@12';
  720. function LpValFindProp; external mapi32 name 'LpValFindProp@12';
  721. function ScCopyProps; external mapi32 name 'ScCopyProps@16';
  722. function ScRelocProps; external mapi32 name 'ScRelocProps@20';
  723. function ScDupPropset; external mapi32 name 'ScDupPropset@16';
  724. function UlAddRef; external mapi32 name 'UlAddRef@4';
  725. function UlRelease; external mapi32 name 'UlRelease@4';
  726. procedure HrGetOneProp; external mapi32 name 'HrGetOneProp@12';
  727. procedure HrSetOneProp; external mapi32 name 'HrSetOneProp@8';
  728. function FPropExists; external mapi32 name 'FPropExists@8';
  729. function PpropFindProp; external mapi32 name 'PpropFindProp@12';
  730. procedure FreePadrlist; external mapi32 name 'FreePadrlist@4';
  731. procedure FreeProws; external mapi32 name 'FreeProws@4';
  732. function HrQueryAllRows; external mapi32 name 'HrQueryAllRows@24';
  733. function ScUNCFromLocalPath; external mapi32 name 'ScUNCFromLocalPath@12';
  734. function ScLocalPathFromUNC; external mapi32 name 'ScLocalPathFromUNC@12';
  735. function FtAddFt; external mapi32 name 'FtAddFt@16';
  736. function FtMulDwDw; external mapi32 name 'FtMulDwDw@8';
  737. function FtMulDw; external mapi32 name 'FtMulDw@12';
  738. function FtSubFt; external mapi32 name 'FtSubFt@16';
  739. function FtNegFt; external mapi32 name 'FtNegFt@8';
  740. function ScCreateConversationIndex; external mapi32 name 'ScCreateConversationIndex@16';
  741. procedure WrapStoreEntryID; external mapi32 name 'WrapStoreEntryID@24';
  742. function RTFSync; external mapi32 name 'RTFSync';
  743. function WrapCompressedRTFStream; external mapi32 name 'WrapCompressedRTFStream';
  744. function HrIStorageFromStream; external mapi32 name 'HrIStorageFromStream@16';
  745. function ScInitMapiUtil; external mapi32 name 'ScInitMapiUtil@4';
  746. procedure DeinitMapiUtil; external mapi32 name 'DeinitMapiUtil@0';
  747. initialization
  748. {$IFNDEF WAB_DYNAMIC_LINK_EXPLICIT}
  749. LoadWabUtil;
  750. {$ENDIF}
  751. finalization
  752. UnloadWabUtil;
  753. end.