' ########################################################################################
' Microsoft Windows
' File: MAPIUtil.inc
' Contents: Definitions and prototypes for utility functions provided by MAPI in MAPI[xx].DLL.
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_MAPIUtil_PBI)
#DEFINE PBX_MAPIUtil_PBI
%EQUATE `MAPIUTIL_INC = 1
#INCLUDE ONCE "Legacy/System/MAPIX.inc"
'/* IMAPITable in memory */
'/* ITableData Interface ---------------------------------------------------- */
'typedef void (STDAPICALLTYPE CALLERRELEASE)(
' ULONG ulCallerData,
' LPTABLEDATA lpTblData,
' LPMAPITABLE lpVue
');
' ========================================================================================
' ITableData interface
' $IID_IMAPITableData = GUID$("{00020316-0000-0000-C000-000000000046}")
' The ITableData interface provides utility methods for working with tables. Table data
' objects -- or objects that implement ITableData -- are provided by MAPI to help service
' providers perform table maintenance. To obtain a table data object, service providers
' call the CreateTable function.
' ========================================================================================
INTERFACE ITableData $IID_ITableData
 INHERIT IUnknown
 ' =====================================================================================
 METHOD HrGetView ( ' VTable offset = 12
 BYVAL lpSSortOrderSet AS SSortOrderSet PTR
 , BYVAL lpfCallerRelease AS DWORD
 , BYVAL ulCallerData AS DWORD
 , BYREF lppMAPITable AS IMAPITable
 ) AS LONG
 ' =====================================================================================
 METHOD HrModifyRow ( ' VTable offset = 16
 BYREF lpSRow AS SRow
 ) AS LONG
 ' =====================================================================================
 METHOD HrDeleteRow ( ' VTable offset = 20
 BYREF lpSPropValue AS SPropValue
 ) AS LONG
 ' =====================================================================================
 METHOD HrQueryRow ( ' VTable offset = 24
 BYREF lpsPropValue AS SPropValue
 , BYREF lppSRow AS DWORD
 , BYVAL lpuliRow AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD HrEnumRow ( ' VTable offset = 28
 BYVAL ulRowNumber AS DWORD
 , BYREF lppSRow AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD HrNotify ( ' VTable offset = 32
 BYVAL ulFlags AS DWORD
 , BYVAL cValues AS DWORD
 , BYREF lpSPropValue AS SPropValue
 ) AS LONG
 ' =====================================================================================
 METHOD HrInsertRow ( ' VTable offset = 36
 BYVAL uliRow AS DWORD
 , BYREF lpSRow AS SRow
 ) AS LONG
 ' =====================================================================================
 METHOD HrModifyRows ( ' VTable offset = 40
 BYVAL ulFlags AS DWORD
 , BYVAL lpSRowSet AS SRowSet PTR
 ) AS LONG
 ' =====================================================================================
 METHOD HrDeleteRows ( ' VTable offset = 44
 BYVAL ulFlags AS DWORD
 , BYVAL lprowsetToDelete AS SRowSet PTR
 , BYREF cRowsDeleted AS DWORD
 ) AS LONG
 ' =====================================================================================
END INTERFACE
'/* Entry Point for in memory ITable */
'/* CreateTable()
' * Creates the internal memory structures and object handle
' * to bring a new table into existence.
' *
' * lpInterface
' * Interface ID of the TableData object (IID_IMAPITableData)
' *
' * lpAllocateBuffer, lpAllocateMore, and lpFreeBuffer
' * Function addresses are provided by the caller so that
' * this DLL allocates/frees memory appropriately.
' * lpvReserved
' * Reserved. Should be NULL.
' * ulTableType
' * TBLTYPE_DYNAMIC, etc. Visible to the calling application
' * as part of the GetStatus return data on its views
' * ulPropTagIndexColumn
' * Index column for use when changing the data
' * lpSPropTagArrayColumns
' * Column proptags for the minimum set of columns in the table
' * lppTableData
' * Address of the pointer which will receive the TableData object
' */
DECLARE FUNCTION CreateTable LIB "mapi32.dll" ALIAS "CreateTable@36" ( BYREF lpInterface AS GUID , BYVAL lpAllocateBuffer AS QUAD , BYVAL lpAllocateMore AS QUAD , BYVAL lpFreeBuffer AS QUAD , BYVAL lpvReserved AS QUAD , BYVAL ulTableType AS QUAD , BYVAL ulPropTagIndexColumn AS QUAD , BYVAL lpSPropTagArrayColumns AS SPropTagArray PTR , BYREF lppTableData AS ITableData ) AS LONG ' SCODE
'/* HrGetView()
' * This function obtains a new view on the underlying data
' * which supports the IMAPITable interface. All rows and columns
' * of the underlying table data are initially visible
' * lpSSortOrderSet
' * if specified, results in the view being sorted
' * lpfCallerRelease
' * pointer to a routine to be called when the view is released, or
' * NULL.
' * ulCallerData
' * arbitrary data the caller wants saved with this view and returned in
' * the Release callback.
' */
'/* HrModifyRows()
' * Add or modify a set of rows in the table data
' * ulFlags
' * Must be zero
' * lpSRowSet
' * Each row in the row set contains all the properties for one row
' * in the table. One of the properties must be the index column. Any
' * row in the table with the same value for its index column is
' * replaced, or if there is no current row with that value the
' * row is added.
' * Each row in LPSRowSet MUST have a unique Index column!
' * If any views are open, the view is updated as well.
' * The properties do not have to be in the same order as the
' * columns in the current table
' */
'/* HrModifyRow()
' * Add or modify one row in the table
' * lpSRow
' * This row contains all the properties for one row in the table.
' * One of the properties must be the index column. Any row in
' * the table with the same value for its index column is
' * replaced, or if there is no current row with that value the
' * row is added
' * If any views are open, the view is updated as well.
' * The properties do not have to be in the same order as the
' * columns in the current table
' */
'/* HrDeleteRows()
' * Delete a row in the table.
' * ulFlags
' * TAD_ALL_ROWS - Causes all rows in the table to be deleted
' * lpSRowSet is ignored in this case.
' * lpSRowSet
' * Each row in the row set contains all the properties for one row
' * in the table. One of the properties must be the index column. Any
' * row in the table with the same value for its index column is
' * deleted.
' * Each row in LPSRowSet MUST have a unique Index column!
' * If any views are open, the view is updated as well.
' * The properties do not have to be in the same order as the
' * columns in the current table
' */
%EQUATE `TAD_ALL_ROWS = 1
'/* HrDeleteRow()
' * Delete a row in the table.
' * lpSPropValue
' * This property value specifies the row which has this value
' * for its index column
' */
'/* HrQueryRow()
' * Returns the values of a specified row in the table
' * lpSPropValue
' * This property value specifies the row which has this value
' * for its index column
' * lppSRow
' * Address of where to return a pointer to an SRow
' * lpuliRow
' * Address of where to return the row number. This can be NULL
' * if the row number is not required.
' *
' */
'/* HrEnumRow()
' * Returns the values of a specific (numbered) row in the table
' * ulRowNumber
' * Indicates row number 0 to n-1
' * lppSRow
' * Address of where to return a pointer to a SRow
' */
'/* HrInsertRow()
' * Inserts a row into the table.
' * uliRow
' * The row number before which this row will be inserted into the table.
' * Row numbers can be from 0 to n where o to n-1 result in row insertion
' * a row number of n results in the row being appended to the table.
' * lpSRow
' * This row contains all the properties for one row in the table.
' * One of the properties must be the index column. Any row in
' * the table with the same value for its index column is
' * replaced, or if there is no current row with that value the
' * row is added
' * If any views are open, the view is updated as well.
' * The properties do not have to be in the same order as the
' * columns in the current table
' */
'/* IMAPIProp in memory */
'/* IPropData Interface ---------------------------------------------------- */
' ========================================================================================
' IPropData interface (inherits from IMAPIProp)
' $IID_IMAPIPropData = GUID$("{0002031A-0000-0000-C000-000000000046}")
' The IPropData interface provides the ability to retrieve and change the access for an
' object's properties.
' ========================================================================================
INTERFACE IPropData $IID_IPropData
 INHERIT IUnknown
 ' =====================================================================================
 ' IMAPIProp Methods
 ' =====================================================================================
 METHOD GetLastError ( ' VTable offser = 12
 BYVAL hResult AS LONG
 , BYVAL ulFlags AS DWORD
 , BYREF lppMAPIError AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD SaveChanges ( ' VTable offser = 16
 BYVAL ulFlags AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetProps ( ' VTable offser = 20
 BYVAL lpPropTagArray AS SPropTagArray PTR
 , BYVAL ulFlags AS DWORD
 , BYREF lpcValues AS DWORD
 , BYREF lppPropArray AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetPropList ( ' VTable offser = 24
 BYVAL ulFlags AS DWORD
 , BYREF lppPropTagArray AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD OpenProperty ( ' VTable offser = 28
 BYVAL ulPropTag AS DWORD
 , BYREF lpiid AS GUID
 , BYVAL ulInterfaceOptions AS DWORD
 , BYVAL ulFlags AS DWORD
 , BYREF lppUnk AS IUnknown
 ) AS LONG
 ' =====================================================================================
 METHOD SetProps ( ' VTable offser = 32
 BYVAL cValues AS DWORD
 , BYVAL lpPropArray AS SPropValue PTR
 , BYVAL lppProblems AS SPropProblemArray PTR
 ) AS LONG
 ' =====================================================================================
 METHOD DeleteProps ( ' VTable offser = 36
 BYVAL lpPropTagArray AS SPropTagArray PTR
 , BYVAL lppProblems AS SPropProblemArray PTR
 ) AS LONG
 ' =====================================================================================
 METHOD CopyTo ( ' VTable offser = 40
 BYVAL ciidExclude AS DWORD
 , BYREF rgiidExclude AS GUID
 , BYVAL lpExcludeProps AS SPropTagArray PTR
 , BYVAL ulUIParam AS DWORD
 , BYVAL lpProgress AS IMAPIProgress
 , BYREF lpInterface AS GUID
 , BYVAL lpDestObj AS DWORD
 , BYVAL ulFlags AS DWORD
 , BYVAL lppProblems AS SPropProblemArray PTR
 ) AS LONG
 ' =====================================================================================
 METHOD CopyProps ( ' VTable offser = 44
 BYVAL lpIncludeProps AS SPropTagArray PTR
 , BYVAL ulUIParam AS DWORD
 , BYVAL lpProgress AS IMAPIProgress
 , BYREF lpInterface AS GUID
 , BYVAL lpDestObj AS DWORD
 , BYVAL ulFlags AS DWORD
 , BYVAL lppProblems AS SPropProblemArray PTR
 ) AS LONG
 ' =====================================================================================
 METHOD GetNamesFromIDs ( ' VTable offser = 48
 BYVAL lppPropTags AS SPropTagArray PTR
 , BYREF lpPropSetGuid AS GUID
 , BYVAL ulFlags AS DWORD
 , BYREF lpcPropNames AS DWORD
 , BYREF lpppPropNames AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetIDsFromNames ( ' VTable offser = 52
 BYVAL cPropNames AS DWORD
 , BYVAL lppPropNames AS MAPINAMEID PTR
 , BYVAL ulFlags AS DWORD
 , BYREF lppPropTags AS DWORD
 ) AS LONG
 ' =====================================================================================
 ' =====================================================================================
 ' IPropData Methods
 ' =====================================================================================
 METHOD HrSetObjAccess ( ' VTable offser = 56
 BYVAL ulAccess AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD HrSetPropAccess ( ' VTable offser = 60
 BYVAL lpPropTagArray AS SPropTagArray PTR
 , BYREF rgulAccess AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD HrGetPropAccess ( ' VTable offser = 64
 BYVAL lppPropTagArray AS SPropTagArray PTR
 , BYREF lprgulAccess AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD HrAddObjProps ( ' VTable offser = 68
 BYVAL lppPropTagArray AS SPropTagArray PTR
 , BYVAL lprgulAccess AS SPropProblemArray PTR
 ) AS LONG
 ' =====================================================================================
END INTERFACE
'/* Entry Point for in memory IMAPIProp */
'/* CreateIProp()
' * Creates the internal memory structures and object handle
' * to bring a new property interface into existance.
' *
' * lpInterface
' * Interface ID of the TableData object (IID_IMAPIPropData)
' *
' * lpAllocateBuffer, lpAllocateMore, and lpFreeBuffer
' * Function addresses are provided by the caller so that
' * this DLL allocates/frees memory appropriately.
' * lppPropData
' * Address of the pointer which will receive the IPropData object
' * lpvReserved
' * Reserved. Should be NULL.
' */
DECLARE FUNCTION CreateIProp LIB "mapi32.dll" ALIAS "CreateIProp@24" ( BYREF lpInterface AS GUID , BYVAL lpAllocateBuffer AS QUAD , BYVAL lpAllocateMore AS QUAD , BYVAL lpFreeBuffer AS QUAD , BYVAL lpvReserved AS QUAD , BYREF lppPropData AS IPropData ) AS LONG ' SCODE
DECLARE FUNCTION WABCreateIProp LIB "mapi32.dll" ALIAS "CreateIProp@24" ( BYREF lpInterface AS GUID , BYVAL lpAllocateBuffer AS QUAD , BYVAL lpAllocateMore AS QUAD , BYVAL lpFreeBuffer AS QUAD , BYVAL lpvReserved AS QUAD , BYREF lppPropData AS IPropData ) AS LONG ' SCODE
'/*
' * Defines for prop/obj access
' */
%EQUATE `IPROP_READONLY = &H00000001
%EQUATE `IPROP_READWRITE = &H00000002
%EQUATE `IPROP_CLEAN = &H00010000
%EQUATE `IPROP_DIRTY = &H00020000
'/*
' - HrSetPropAccess
' -
' * Sets access right attributes on a per-property basis. By default,
' * all properties are read/write.
' *
' */
'/*
' - HrSetObjAccess
' -
' * Sets access rights for the object itself. By default, the object has
' * read/write access.
' *
' */
#IF NOT %DEF(%NOIDLEENGINE)
'/* Idle time scheduler */
'/*
' * PRI
' *
' * Priority of an idle task.
' * The idle engine sorts tasks by priority, and the one with the higher
' * value runs first. Within a priority level, the functions are called
' * round-robin.
' */
%EQUATE `PRILOWEST = -32768
%EQUATE `PRIHIGHEST = 32767
%EQUATE `PRIUSER = 0
'/*
' * IRO
' *
' * Idle routine options. This is a combined bit mask consisting of
' * individual firo's. Listed below are the possible bit flags.
' *
' * FIROWAIT and FIROINTERVAL are mutually exclusive.
' * If neither of the flags are specified, the default action
' * is to ignore the time parameter of the idle function and
' * call it as often as possible if firoPerBlock is not set;
' * otherwise call it one time only during the idle block
' * once the time constraint has been set. FIROINTERVAL
' * is also incompatible with FIROPERBLOCK.
' *
' * FIROWAIT - time given is minimum idle time before calling
' * for the first time in the block of idle time,
' * afterwhich call as often as possible.
' * FIROINTERVAL - time given is minimum interval between each
' * successive call
' * FIROPERBLOCK - called only once per contiguous block of idle
' * time
' * FIRODISABLED - initially disabled when registered, the
' * default is to enable the function when registered.
' * FIROONCEONLY - called only one time by the scheduler and then
' * deregistered automatically.
' */
%EQUATE `IRONULL = &H0000
%EQUATE `FIROWAIT = &H0001
%EQUATE `FIROINTERVAL = &H0002
%EQUATE `FIROPERBLOCK = &H0004
%EQUATE `FIRODISABLED = &H0020
%EQUATE `FIROONCEONLY = &H0040
'/*
' * IRC
' *
' * Idle routine change options. This is a combined bit mask consisting
' * of individual firc's; each one identifies an aspect of the idle task
' * that can be changed.
' *
' */
%EQUATE `IRCNULL = &H0000
%EQUATE `FIRCPFN = &H0001 ' /* change function pointer */
%EQUATE `FIRCPV = &H0002 ' /* change parameter block */
%EQUATE `FIRCPRI = &H0004 ' /* change priority */
%EQUATE `FIRCCSEC = &H0008 ' /* change time */
%EQUATE `FIRCIRO = &H0010 ' /* change routine options */
'/*
' * Type definition for idle functions. An idle function takes one
' * parameter, an PV, and returns a BOOL value.
' */
'typedef BOOL (STDAPICALLTYPE FNIDLE) (LPVOID);
'typedef FNIDLE *PFNIDLE;
'/*
' * FTG
' *
' * Function Tag. Used to identify a registered idle function.
' *
' */
'typedef void *FTG;
'typedef FTG *PFTG;
'#define FTGNULL ((FTG) NULL)
'/*
' - MAPIInitIdle/MAPIDeinitIdle
' -
' * Purpose:
' * Initialises the idle engine
' * If the initialisation succeded, returns 0, else returns -1
' *
' * Arguments:
' * lpvReserved Reserved, must be NULL.
' */
DECLARE FUNCTION MAPIInitIdle LIB "mapi32.dll" ALIAS "MAPIInitIdle@4" ( BYVAL lpvReserved AS QUAD ) AS LONG
DECLARE SUB MAPIDeInitIdle LIB "mapi32.dll" ALIAS "MAPIDeInitIdle@0" ()
'/*
' * FtgRegisterIdleRoutine
' *
' * Registers the function pfn of type PFNIDLE, i.e., (BOOL (*)(LPVOID))
' * as an idle function.
' *
' * The idle function will be called with the parameter pv by the
' * idle engine. The function has initial priority priIdle,
' * associated time csecIdle, and options iroIdle.
' */
DECLARE FUNCTION FtgRegisterIdleRoutine LIB "mapi32.dll" ALIAS "FtgRegisterIdleRoutine@20" ( BYVAL pfnIdle AS QUAD , BYVAL pvIdleParam AS QUAD , BYVAL priIdle AS INTEGER , BYVAL csecIdle AS QUAD , BYVAL iroIdle AS WORD ) AS QUAD ' FTG
'/*
' * DeregisterIdleRoutine
' *
' * Removes the given routine from the list of idle routines.
' * The routine will not be called again. It is the responsibility
' * of the caller to clean up any data structures pointed to by the
' * pvIdleParam parameter; this routine does not free the block.
' */
DECLARE SUB DeregisterIdleRoutine LIB "mapi32.dll" ALIAS "DeregisterIdleRoutine@4" ( BYVAL ftg AS QUAD ) ' void
'/*
' * EnableIdleRoutine
' *
' * Enables or disables an idle routine.
' */
DECLARE SUB EnableIdleRoutine LIB "mapi32.dll" ALIAS "EnableIdleRoutine@8" ( BYVAL ftg AS QUAD , BYVAL fEnable AS LONG ) ' void
'/*
' * ChangeIdleRoutine
' *
' * Changes some or all of the characteristics of the given idle
' * function. The changes to make are indicated with flags in the
' * ircIdle parameter.
' */
DECLARE SUB ChangeIdleRoutine LIB "mapi32.dll" ALIAS "ChangeIdleRoutine@28" ( BYVAL ftg AS QUAD , BYVAL pfnIdle AS QUAD , BYVAL pvIdleParam AS QUAD , BYVAL priIdle AS INTEGER , BYVAL csecIdle AS QUAD , BYVAL iroIdle AS WORD , BYVAL ircIdle AS WORD ) ' void
#ENDIF ' /* ! NOIDLEENGINE */
'/* IMalloc Utilities */
DECLARE FUNCTION MAPIGetDefaultMalloc LIB "mapi32.dll" ALIAS "MAPIGetDefaultMalloc@0" () AS QUAD
'/* StreamOnFile (SOF) */
'/*
' * Methods and #define's for implementing an OLE 2.0 storage stream
' * (as defined in the OLE 2.0 specs) on top of a system file.
' */
%EQUATE `SOF_UNIQUEFILENAME = &H80000000&
DECLARE FUNCTION OpenStreamOnFile LIB "mapi32.dll" ALIAS "OpenStreamOnFile" ( BYVAL lpAllocateBuffer AS QUAD , BYVAL lpFreeBuffer AS QUAD , BYVAL ulFlags AS QUAD , BYREF lpszFileName AS ASCIIZ , BYREF lpszPrefix AS ASCIIZ , BYREF lppStream AS IStream ) AS LONG
$OPENSTREAMONFILE = "OpenStreamOnFile"
'/* Property interface utilities */
'/*
' * Copies a single SPropValue from Src to Dest. Handles all the various
' * types of properties and will link its allocations given the master
' * allocation object and an allocate more function.
' */
DECLARE FUNCTION PropCopyMore LIB "mapi32.dll" ALIAS "PropCopyMore@16" ( BYREF lpSPropValueDest AS SPropValue , BYREF lpSPropValueSrc AS SPropValue , BYVAL lpfAllocMore AS QUAD , BYVAL lpvObject AS QUAD ) AS LONG ' SCODE
'/*
' * Returns the size in bytes of structure at lpSPropValue, including the
' * Value.
' */
DECLARE FUNCTION UlPropSize LIB "mapi32.dll" ALIAS "UlPropSize@4" ( BYREF lpSPropValue AS SPropValue ) AS QUAD ' ULONG
DECLARE FUNCTION FEqualNames LIB "mapi32.dll" ALIAS "FEqualNames@8" ( BYREF lpName1 AS MAPINAMEID , BYREF lpName2 AS MAPINAMEID ) AS LONG
DECLARE SUB GetInstance LIB "mapi32.dll" ALIAS "GetInstance" ( BYREF pvalMv AS SPropValue
 , BYREF pvalSv AS SPropValue
 , BYVAL uliInst AS DWORD
 ) ' void
'extern char rgchCsds[];
'extern char rgchCids[];
'extern char rgchCsdi[];
'extern char rgchCidi[];
DECLARE FUNCTION FPropContainsProp LIB "mapi32.dll" ALIAS "FPropContainsProp@12" ( BYREF lpSPropValueDst AS SPropValue , BYREF lpSPropValueSrc AS SPropValue , BYVAL ulFuzzyLevel AS QUAD ) AS LONG
DECLARE FUNCTION FPropCompareProp LIB "mapi32.dll" ALIAS "FPropCompareProp@12" ( BYREF lpSPropValue1 AS SPropValue
 , BYVAL ulRelOp AS DWORD
 , BYREF lpSPropValue2 AS SPropValue
 ) AS LONG
DECLARE FUNCTION LPropCompareProp LIB "mapi32.dll" ALIAS "LPropCompareProp@8" ( BYREF lpSPropValueA AS SPropValue
 , BYREF lpSPropValueB AS SPropValue
 ) AS LONG
DECLARE FUNCTION HrAddColumns LIB "mapi32.dll" ALIAS "HrAddColumns@16" ( BYVAL lptbl AS IMAPITable
 , BYVAL lpproptagColumnsNew AS SPropTagArray PTR
 , BYVAL lpAllocateBuffer AS DWORD
 , BYVAL lpFreeBuffer AS DWORD
 ) AS LONG
DECLARE FUNCTION HrAddColumnsEx LIB "mapi32.dll" ALIAS "HrAddColumnsEx@20" ( BYVAL lptbl AS IMAPITable
 , BYVAL lpproptagColumnsNew AS SPropTagArray PTR
 , BYVAL lpAllocateBuffer AS DWORD
 , BYVAL lpFreeBuffer AS DWORD
 , BYVAL lpfnFilterColumns AS DWORD
 ) AS LONG
'/* Notification utilities */
'/*
' * Function that creates an advise sink object given a notification
' * callback function and context.
' */
DECLARE FUNCTION HrAllocAdviseSink LIB "mapi32.dll" ALIAS "HrAllocAdviseSink" ( BYVAL lpfnCallback AS QUAD , BYVAL lpvContext AS QUAD , BYREF lppAdviseSink AS IMAPIAdviseSink ) AS LONG
'/*
' * Wraps an existing advise sink with another one which guarantees
' * that the original advise sink will be called in the thread on
' * which it was created.
' */
DECLARE FUNCTION HrThisThreadAdviseSink LIB "mapi32.dll" ALIAS "HrThisThreadAdviseSink@8" ( BYVAL lpAdviseSink AS IMAPIAdviseSink , BYREF lppAdviseSink AS IMAPIAdviseSink ) AS LONG
'/*
' * Allows a client and/or provider to force notifications
' * which are currently queued in the MAPI notification engine
' * to be dispatched without doing a message dispatch.
' */
DECLARE FUNCTION HrDispatchNotifications LIB "mapi32.dll" ALIAS "HrDispatchNotifications@4" ( BYVAL ulFlags AS QUAD ) AS LONG
'/* Service Provider Utilities */
'/*
' * Structures and utility function for building a display table
' * from resources.
' */
'typedef struct {
' ULONG ulCtlType; /* DTCT_LABEL, etc. */
' ULONG ulCtlFlags; /* DT_REQUIRED, etc. */
' LPBYTE lpbNotif; /* pointer to notification data */
' ULONG cbNotif; /* count of bytes of notification data */
' LPTSTR lpszFilter; /* character filter for edit/combobox */
' ULONG ulItemID; /* to validate parallel dlg template entry */
' union { /* ulCtlType discriminates */
' LPVOID lpv; /* Initialize this to avoid warnings */
' LPDTBLLABEL lplabel;
' LPDTBLEDIT lpedit;
' LPDTBLLBX lplbx;
' LPDTBLCOMBOBOX lpcombobox;
' LPDTBLDDLBX lpddlbx;
' LPDTBLCHECKBOX lpcheckbox;
' LPDTBLGROUPBOX lpgroupbox;
' LPDTBLBUTTON lpbutton;
' LPDTBLRADIOBUTTON lpradiobutton;
' LPDTBLMVLISTBOX lpmvlbx;
' LPDTBLMVDDLBX lpmvddlbx;
' LPDTBLPAGE lppage;
' } ctl;
'} DTCTL, *LPDTCTL;
' // Size = 4 bytes
UNION DTCTL_UNION
 lpv AS DWORD
 lplabel AS DTBLLABEL PTR
 lpedit AS DTBLEDIT PTR
 lplbx AS DTBLLBX PTR
 lpcombobox AS DTBLCOMBOBOX PTR
 lpddlbx AS DTBLDDLBX PTR
 lpcheckbox AS DTBLCHECKBOX PTR
 lpgroupbox AS DTBLGROUPBOX PTR
 lpbutton AS DTBLBUTTON PTR
 lpradiobutton AS DTBLRADIOBUTTON PTR
 lpmvlbx AS DTBLMVLISTBOX PTR
 lpmvddlbx AS DTBLMVDDLBX PTR
 lppage AS DTBLPAGE PTR
END UNION
' // Size = 28 bytes
TYPE DTCTL DWORD
 ulCtlType AS DWORD ' ULONG
 ulCtlFlags AS DWORD ' ULONG
 lpbNotif AS GUID PTR
 cbNotif AS DWORD ' ULONG
 lpszFilter AS ASCIIZ PTR
 ulItemID AS DWORD ' ULONG
 ctl AS DTCTL_UNION
END TYPE
'typedef struct {
' ULONG cctl;
' LPTSTR lpszResourceName; /* as usual, may be an integer ID */
' union { /* as usual, may be an integer ID */
' LPTSTR lpszComponent;
' ULONG ulItemID;
' };
' LPDTCTL lpctl;
'} DTPAGE, *LPDTPAGE;
' // Size = 4 bytes
UNION DTPAGE_UNION DWORD
 lpszComponent AS ASCIIZ PTR
 ulItemID AS DWORD ' ULONG
END UNION
' // Size = 16 bytes
TYPE DTPAGE
 cctl AS DWORD ' ULONG
 lpszResourceName AS ASCIIZ PTR
 DTPAGE_UNION
 lpctl AS DWORD ' LPDTCTL [array]
END TYPE
DECLARE FUNCTION BuildDisplayTable LIB "mapi32.dll" ALIAS "BuildDisplayTable@40" ( BYVAL lpAllocateBuffer AS QUAD , BYVAL lpAllocateMore AS QUAD , BYVAL lpFreeBuffer AS QUAD , BYVAL lpMalloc AS IMalloc , BYVAL hInstance AS QUAD , BYVAL cPages AS QUAD , BYREF lpPage AS DTPAGE , BYVAL ulFlags AS QUAD , BYREF lppTable AS IMAPITable , BYREF lppTblData AS ITableData ) AS LONG
'/* MAPI structure validation/copy utilities */
'/*
' * Validate, copy, and adjust pointers in MAPI structures:
' * notification
' * property value array
' * option data
' */
DECLARE FUNCTION ScCountNotifications LIB "mapi32.dll" ALIAS "ScCountNotifications@12" ( BYVAL cntf AS LONG , BYREF rgntf AS NOTIFICATION , BYREF pcb AS QUAD ) AS LONG ' SCODE
DECLARE FUNCTION ScCopyNotifications LIB "mapi32.dll" ALIAS "ScCopyNotifications@16" ( BYVAL cntf AS LONG , BYREF rgntf AS NOTIFICATION , BYVAL pvDst AS QUAD , BYREF pcb AS QUAD ) AS LONG ' SCODE
DECLARE FUNCTION ScRelocNotifications LIB "mapi32.dll" ALIAS "ScRelocNotifications@20" ( BYVAL cntf AS LONG , BYREF rgntf AS NOTIFICATION , BYVAL pvBaseOld AS QUAD , BYVAL pvBaseNew AS QUAD , BYREF pcb AS QUAD ) AS LONG ' SCODE
DECLARE FUNCTION ScCountProps LIB "mapi32.dll" ALIAS "ScCountProps@12" ( BYVAL cprop AS LONG , BYREF rgprop AS SPropValue , BYREF pcb AS QUAD ) AS LONG ' SCODE
DECLARE FUNCTION LpValFindProp LIB "mapi32.dll" ALIAS "LpValFindProp@12" ( BYVAL ulPropTag AS QUAD , BYVAL cValues AS QUAD , BYREF lpPropArray AS SPropValue ) AS LONG ' SCODE
DECLARE FUNCTION ScCopyProps LIB "mapi32.dll" ALIAS "ScCopyProps@16" ( BYVAL cprop AS LONG , BYREF rgprop AS SPropValue , BYVAL pvDst AS QUAD , BYREF pcb AS QUAD ) AS LONG ' SCODE
DECLARE FUNCTION ScRelocProps LIB "mapi32.dll" ALIAS "ScRelocProps@20" ( BYVAL cprop AS LONG , BYREF rgprop AS SPropValue , BYVAL pvBaseOld AS QUAD , BYVAL pvBaseNew AS QUAD , BYREF pcb AS QUAD ) AS LONG ' SCODE
DECLARE FUNCTION ScDupPropset LIB "mapi32.dll" ALIAS "ScDupPropset@16" ( BYVAL cprop AS LONG , BYVAL rgprop AS QUAD , BYVAL lpAllocateBuffer AS QUAD , BYREF prgprop AS QUAD ) AS LONG ' SCODE
'/* General utility functions */
'/* Related to the OLE Component object model */
DECLARE FUNCTION UlAddRef LIB "mapi32.dll" ALIAS "UlAddRef@4" ( BYVAL punk AS QUAD ) AS QUAD ' ULONG
DECLARE FUNCTION UlRelease LIB "mapi32.dll" ALIAS "UlRelease@4" ( BYVAL punk AS QUAD ) AS QUAD ' ULONG
'/* Related to the MAPI interface */
DECLARE FUNCTION HrGetOneProp LIB "mapi32.dll" ALIAS "HrGetOneProp@12" ( BYVAL pmp AS IMAPIProp , BYVAL ulPropTag AS QUAD , BYREF ppprop AS QUAD ) AS LONG
DECLARE FUNCTION HrSetOneProp LIB "mapi32.dll" ALIAS "HrSetOneProp@8" ( BYVAL pmp AS IMAPIProp
 , BYREF pprop AS SPropValue
 ) AS LONG
DECLARE FUNCTION FPropExists LIB "mapi32.dll" ALIAS "FPropExists@8" ( BYVAL pobj AS IMAPIProp
 , BYVAL ulPropTag AS DWORD
 ) AS LONG
DECLARE FUNCTION PpropFindProp LIB "mapi32.dll" ALIAS "PpropFindProp@12" ( BYREF rgprop AS SPropValue
 , BYVAL cprop AS DWORD
 , BYVAL ulPropTag AS DWORD
 ) AS DWORD ' LPSPropValue
DECLARE SUB FreePadrlist LIB "mapi32.dll" ALIAS "FreePadrlist@4" ( BYVAL padrlist AS ADRLIST PTR ) ' void
DECLARE SUB FreeProws LIB "mapi32.dll" ALIAS "FreeProws@4" ( BYVAL prows AS SRowSet PTR ) ' void
DECLARE FUNCTION HrQueryAllRows LIB "mapi32.dll" ALIAS "HrQueryAllRows@24" ( BYVAL ptable AS IMAPITable , BYVAL ptaga AS SPropTagArray PTR , BYREF pres AS SRestriction , BYVAL psos AS SSortOrderSet PTR , BYVAL crowsMax AS QUAD , BYREF pprows AS QUAD ) AS LONG
'/* Create or validate the IPM folder tree in a message store */
%EQUATE `MAPI_FORCE_CREATE = 1
%EQUATE `MAPI_FULL_IPM_TREE = 2
DECLARE FUNCTION HrValidateIPMSubtree LIB "mapi32.dll" ALIAS "HrValidateIPMSubtree@20" ( BYVAL lpMDB AS IMsgStore , BYVAL ulFlags AS QUAD , BYREF lpcValues AS QUAD , BYVAL lppProps AS SPropValue PTR , BYREF lppMapiError AS QUAD ) AS LONG
'/* Encoding and decoding strings */
DECLARE FUNCTION FBinFromHex LIB "mapi32.dll" ALIAS "FBinFromHex@8" ( BYREF sz AS ASCIIZ , BYREF pb AS ANY ) AS LONG
DECLARE FUNCTION ScBinFromHexBounded LIB "mapi32.dll" ALIAS "ScBinFromHexBounded@12" ( BYREF sz AS ASCIIZ
 , BYREF pb AS ANY
 , BYVAL cb AS DWORD
 ) AS LONG ' SCODE
DECLARE SUB HexFromBin LIB "mapi32.dll" ALIAS "HexFromBin@12" ( BYVAL pb AS BYTE PTR , BYVAL cb AS LONG , BYREF sz AS ASCIIZ ) ' void
DECLARE FUNCTION UlFromSzHex LIB "mapi32.dll" ALIAS "UlFromSzHex@4" ( BYREF lpsz AS ASCIIZ ) AS QUAD ' ULONG
'/* Encoding and decoding entry IDs */
DECLARE FUNCTION HrEntryIDFromSz LIB "mapi32.dll" ALIAS "HrEntryIDFromSz@12" ( BYREF sz AS ASCIIZ , BYREF pcb AS QUAD , BYREF ppentry AS QUAD ) AS LONG
DECLARE FUNCTION HrSzFromEntryID LIB "mapi32.dll" ALIAS "HrSzFromEntryID@12" ( BYVAL cb AS QUAD
 , BYVAL pentry AS ENTRYID PTR
 , BYREF psz AS DWORD
 ) AS LONG
DECLARE FUNCTION HrComposeEID LIB "mapi32.dll" ALIAS "HrComposeEID@28" ( BYVAL psession AS IMAPISession
 , BYVAL cbStoreRecordKey AS DWORD
 , BYVAL pStoreRecordKey AS BYTE PTR
 , BYVAL cbMsgEID AS DWORD
 , BYVAL pMsgEID AS ENTRYID PTR
 , BYREF pcbEID AS DWORD
 , BYREF ppEID AS DWORD
 ) AS LONG
DECLARE FUNCTION HrDecomposeEID LIB "mapi32.dll" ALIAS "HrDecomposeEID@24" ( BYVAL psession AS IMAPISession
 , BYVAL cbEID AS DWORD
 , BYVAL pEID AS ENTRYID PTR
 , BYREF pcbStoreEID AS DWORD
 , BYREF ppStoreEID AS DWORD
 , BYREF pcbMsgEID AS DWORD
 , BYREF ppMsgEID AS DWORD
 ) AS LONG
DECLARE FUNCTION HrComposeMsgID LIB "mapi32.dll" ALIAS "HrComposeMsgID@24" ( BYVAL psession AS IMAPISession
 , BYVAL cbStoreRecordKey AS DWORD
 , BYVAL pStoreRecordKey AS BYTE PTR
 , BYVAL cbMsgEID AS DWORD
 , BYVAL pMsgEID AS ENTRYID PTR
 , BYREF pszMsgID AS DWORD
 ) AS LONG
DECLARE FUNCTION HrDecomposeMsgID LIB "mapi32.dll" ALIAS "HrDecomposeMsgID" ( BYVAL psession AS IMAPISession
 , BYREF szMsgID AS ASCIIZ
 , BYREF pcbStoreEID AS DWORD
 , BYREF ppStoreEID AS DWORD
 , BYREF pcbMsgEID AS DWORD
 , BYREF ppMsgEID AS DWORD
 ) AS LONG
'/* C runtime substitutes */
DECLARE FUNCTION SzFindCh LIB "mapi32.dll" ALIAS "SzFindCh@8" ( BYREF lpsz AS ASCIIZ , BYVAL ch AS WORD ) AS QUAD
DECLARE FUNCTION SzFindLastCh LIB "mapi32.dll" ALIAS "SzFindLastCh@8" ( BYREF lpsz AS ASCIIZ
 , BYVAL ch AS WORD
 ) AS DWORD
DECLARE FUNCTION SzFindSz LIB "mapi32.dll" ALIAS "SzFindSz@8" ( BYREF lpsz AS ASCIIZ
 , BYREF lpszKey AS ASCIIZ
 ) AS DWORD
DECLARE FUNCTION UFromSz LIB "mapi32.dll" ALIAS "UFromSz@4" ( BYREF lpsz AS ASCIIZ
 ) AS DWORD ' UINT
DECLARE FUNCTION ScUNCFromLocalPath LIB "mapi32.dll" ALIAS "ScUNCFromLocalPath@12" ( BYREF szLocal AS ASCIIZ , BYREF szUNC AS ASCIIZ , BYVAL cchUNC AS QUAD ) AS LONG ' SCODE
DECLARE FUNCTION ScLocalPathFromUNC LIB "mapi32.dll" ALIAS "ScLocalPathFromUNC@12" ( BYREF szUNC AS ASCIIZ , BYREF szLocal AS ASCIIZ , BYVAL cchLocal AS QUAD ) AS LONG ' SCODE
'/* 64-bit arithmetic with times */
DECLARE FUNCTION FtAddFt LIB "mapi32.dll" ALIAS "FtAddFt@16" ( BYVAL Addend1 AS FILETIME , BYVAL Addend2 AS FILETIME ) AS QUAD ' FILETIME
DECLARE FUNCTION FtMulDwDw LIB "mapi32.dll" ALIAS "FtMulDwDw@8" ( BYVAL Multiplicand AS QUAD , BYVAL Multiplier AS QUAD ) AS QUAD ' FILETIME
DECLARE FUNCTION FtMulDw LIB "mapi32.dll" ALIAS "FtMulDw@12" ( BYVAL Multiplier AS QUAD , BYVAL Multiplicand AS FILETIME ) AS QUAD ' FILETIME
DECLARE FUNCTION FtSubFt LIB "mapi32.dll" ALIAS "FtSubFt@16" ( BYVAL Minuend AS FILETIME , BYVAL Subtrahend AS FILETIME ) AS QUAD ' FILETIME
DECLARE FUNCTION FtNegFt LIB "mapi32.dll" ALIAS "FtNegFt@8" ( BYVAL ft AS FILETIME ) AS QUAD ' FILETIME
'/* Message composition */
DECLARE FUNCTION ScCreateConversationIndex LIB "mapi32.dll" ALIAS "ScCreateConversationIndex@16" ( BYVAL cbParent AS QUAD ' ULONG cbParent , BYVAL lpbParent AS BYTE PTR ' LPBYTE lpbParent , BYREF lpcbConvIndex AS QUAD ' ULONG * lpcbConvIndex , BYREF lppbConvIndex AS ANY ' LPBYTE * lppbConvIndex ) AS LONG ' SCODE
'/* Store support */
DECLARE FUNCTION WrapStoreEntryID LIB "mapi32.dll" ALIAS "WrapStoreEntryID@24" ( BYVAL ulFlags AS QUAD , BYREF szDLLName AS ASCIIZ , BYVAL cbOrigEntry AS QUAD , BYVAL lpOrigEntry AS ENTRYID PTR , BYREF lpcbWrappedEntry AS QUAD , BYREF lppWrappedEntry AS QUAD ) AS LONG
'/* RTF Sync Utilities */
%EQUATE `RTF_SYNC_RTF_CHANGED = &H00000001&
%EQUATE `RTF_SYNC_BODY_CHANGED = &H00000002&
DECLARE FUNCTION RTFSync LIB "mapi32.dll" ALIAS "RTFSync" ( BYVAL lpMessage AS IMessage , BYVAL ulFlags AS QUAD , BYREF lpfMessageUpdated AS LONG ) AS LONG
'/* Flags for WrapCompressedRTFStream() */
'/****** MAPI_MODIFY ((ULONG) 0x00000001) mapidefs.h */
'/****** STORE_UNCOMPRESSED_RTF ((ULONG) 0x00008000) mapidefs.h */
DECLARE FUNCTION WrapCompressedRTFStream LIB "mapi32.dll" ALIAS "WrapCompressedRTFStream" ( BYVAL lpCompressedRTFStream AS IStream , BYVAL ulflags AS QUAD , BYREF lpUncompressedRTFStream AS IStream ) AS LONG
'/* Storage on Stream */
'#if defined(_WIN32) || defined(WIN16)
DECLARE FUNCTION HrIStorageFromStream LIB "mapi32.dll" ALIAS "HrIStorageFromStream" ( BYVAL lpUnkIn AS IUnknown ) AS LONG ' LPUNKNOWN lpUnkIn , BYREF lpInterface AS GUID ' PIID lpInterface , BYVAL ulFlags AS QUAD ' ULONG ulFlags , BYREF lppStorageOut AS IStorage ' LPSTORAGE * lppStorageOut
'#endif
'/*
' * Setup and cleanup.
' *
' * Providers never need to make these calls.
' *
' * Test applications and the like which do not call MAPIInitialize
' * may want to call them, so that the few utility functions which
' * need MAPI allocators (and do not ask for them explicitly)
' * will work.
' */
'/* All flags are reserved for ScInitMapiUtil. */
DECLARE FUNCTION ScInitMapiUtil LIB "mapi32.dll" ALIAS "ScInitMapiUtil@4" ( BYVAL ulFlags AS QUAD ) AS LONG ' SCODE
DECLARE SUB DeinitMapiUtil LIB "mapi32.dll" ALIAS "DeinitMapiUtil@0" ()
'/*
' * Entry point names.
' *
' * These are for new entry points defined since MAPI first shipped
' * in Windows 95. Using these names in a GetProcAddress call makes
' * it easier to write code which uses them optionally.
' */
'#if defined (WIN16)
'#define szHrDispatchNotifications "HrDispatchNotifications"
'#elif defined (_WIN32) && defined (_X86_)
'#define szHrDispatchNotifications "_HrDispatchNotifications@4"
'#elif defined (_ALPHA_) || defined (_MIPS_) || defined (_PPC_) || defined(_IA64_)
'#define szHrDispatchNotifications "HrDispatchNotifications"
'#endif
$szHrDispatchNotifications = "HrDispatchNotifications@4"
'typedef HRESULT (STDAPICALLTYPE DISPATCHNOTIFICATIONS)(ULONG ulFlags);
'typedef DISPATCHNOTIFICATIONS * LPDISPATCHNOTIFICATIONS;
'#if defined (WIN16)
'#define szScCreateConversationIndex "ScCreateConversationIndex"
'#elif defined (_WIN32) && defined (_X86_)
'#define szScCreateConversationIndex "_ScCreateConversationIndex@16"
'#elif defined (_ALPHA_) || defined (_MIPS_) || defined (_PPC_) || defined(_IA64_)
'#define szScCreateConversationIndex "ScCreateConversationIndex"
'#endif
$szScCreateConversationIndex = "ScCreateConversationIndex@16"
'typedef SCODE (STDAPICALLTYPE CREATECONVERSATIONINDEX)(ULONG cbParent,
' LPBYTE lpbParent, ULONG *lpcbConvIndex, LPBYTE *lppbConvIndex);
'typedef CREATECONVERSATIONINDEX *LPCREATECONVERSATIONINDEX;
#ENDIF
