|
|
|
Windows Address Book Reference |
|
This section contains the reference for the Microsoft Windows Address Book (WAB) application programming interface (API).
Microsoft Windows provides an address book for storing contact information. The Windows Address Book (WAB) is an application and service that enables users to keep track of people. The WAB has a local database and user interface for finding and editing information about people, and it can query network directory servers using Lightweight Directory Access Protocol (LDAP). Other applications can use the WAB. For example, Microsoft Outlook uses the WAB as its e-mail address book.
The following overview topics discuss how to use the WAB.
|
|
Interfaces |
|
|
|
|
|
Functions |
|
WABOpen |
|
Provides access to the address book
through a number of object interfaces. The root interface is IAddrBook,
which is a subset of the MAPI implementation of IAddrBook. |
|
WABOpenEx |
|
Provides access to the Microsoft
Windows Address Book (WAB) through a number of object interfaces. The root
interface is IAddrBook, which is a subset of the MAPI implementation of
IAddrBook. Note When you specify memory
allocation routines with WABOpenEx, these routines globally replace the WAB
internal routines for this process. Other threads may still call WABOpen,
but the memory will be allocated with those routines previously passed to
WABOpenEx. |
|
LoadWABLibrary |
|
Retrieves the path of the WAB32.DLL and loads it into memory.
$WAB_DLL_NAME =
"WAB32.DLL"
FUNCTION LoadWABLibrary
(BYREF hLib AS DWORD)
AS LONG |
|
TB_WABOpen |
|
Wrapper function for WABOpen.
FUNCTION TB_WABOpen
( _
CALL DWORD pProcAddress
USING WABOpen (lppAdrBook, lppWABObject,
lpWABParam, 0) TO hr |
|
TB_WABOpenEx |
|
Wrapper function for WABOpenEx.
FUNCTION TB_WABOpenEx
( _
CALL DWORD pProcAddress
USING WABOpenEx (lppAdrBook, lppWABObject,
lpWABParam, 0, lpfnAllocateBuffer, lpfnAllocateMore, lpfnFreeBuffer)
TO hr |
|
Structures |
|
ADRENTRY |
|
Describes zero or more properties
belonging to one or more recipients. |
|
ADRLIST |
|
Describes zero or more properties
belonging to one or more recipients. |
|
ADRPARM |
|
Describes the display and behavior of
the common address dialog box.
|
|
ENTRYID |
|
Contains the entry identifier
information for a MAPI object.
ab |
|
ENTRYLIST |
|
An array of entry identifiers
representing MAPI objects. Uses the same implementation as SBinaryArray.
lpbin |
|
SPropProblem |
|
Describes an error relating to an
operation involving a property.
ulPropTag
scode |
|
SPropProblemArray |
|
Contains an array of one or more
SPropProblem structures.
aProblem |
|
SPropTagArray |
|
Contains an array of property tags.
aulPropTag |
|
SPropValue |
|
Contains the property tag values.
|
|
SRestriction |
|
Describes a filter for limiting the
view of a table to particular rows. |
|
SRow |
|
Describes a row from a table
containing selected properties for a specific object.
cValues
lpProps |
|
SRowSet |
|
Contains an array of SRow structures.
Each SRow structure describes a row from a table.
aRow |
|
SSortOrder |
|
Defines how to sort rows of a table,
describing both the column to use as the sort key and the direction of the
sort. ulOrder |
|
SSortOrderSet |
|
Defines a collection of keys for a
table to be used for standard or categorized sorting.
cCategories
cExpanded
aSort |
|
WAB_PARAM |
|
Contains the input information to
pass to WABOpen.
|
|
WABEXTDISPLAY |
|
Used by the Microsoft Windows Address
Book (WAB) to initialize user's IContextMenu and IShellPropSheetExt
implementations. lpWABObject lpAdrBook lpPropObj fReadOnly fDataChanged ulFlags
lpsz |
|
WABIMPORTPARAM |
|
Structure passed to
IWABObject::Import that gives information about importing .wab files. lpAdrBook hwnd ulFlags |
|
Enumerations |
|
Gender |
|
The Gender enumeration
specifies the possible values for the PR_GENDER property. |
|
WAB Example |
' ****************************************************************************************
' WAB Example
' ****************************************************************************************
#COMPILE EXE
#DIM ALL
#DEBUG ERROR ON
#INCLUDE "Win32Api.inc"
#INCLUDE "TB_MAPIX.INC"
' ****************************************************************************************
' Main
' ****************************************************************************************
FUNCTION PBMAIN () AS LONG
LOCAL hr AS LONG ' // HRESULT
LOCAL hWabLib AS DWORD ' // Handle of the WAB library
LOCAL wp AS WAB_PARAM ' // WAB_PARAM structure
LOCAL ppIAddrBook AS DWORD ' // IAddrBook interface pointer
LOCAL ppIWABObject AS DWORD ' // IWABObject interface pointer
LOCAL cbEntryID AS DWORD ' // Size of the entry identifier
LOCAL pEntryID AS ENTRYID PTR ' // Pointer to an ENTRYID structure
LOCAL ulFlags AS DWORD ' // Flags
LOCAL ulObjType AS DWORD ' // Object type
LOCAL IID_IABContainer AS GUID ' // IABContainer IID
LOCAL ppIABCOntainer AS DWORD ' // IABContainer interface pointer
LOCAL ppIABTable AS DWORD ' // IABTable interface pointer
LOCAL ulRows AS DWORD ' // Number of rows
LOCAL dwRowSet AS DWORD
LOCAL pRowSet AS SRowSet PTR ' // Pointer to a SRowset structure
LOCAL cRows AS DWORD ' // Number of rows
LOCAL pRow AS SRow PTR ' // Pointer to a SRow structure
LOCAL i AS LONG ' // Loop counter
LOCAL x AS LONG ' // Loop counter
LOCAL pProp AS SPropValue PTR ' // Pointer to a SPropValue structure
LOCAL cValues AS DWORD
LOCAL ppIMailUser AS DWORD
' Load the WAB library
hr = LoadWABLibrary(hWabLib)
IF ISTRUE hr THEN
MSGBOX "LoadWABLibrary - Error: " & HEX$(hr)
EXIT FUNCTION
END IF
' Initialize the WAB_PARM structure
wp.cbsize = SIZEOF(WAB_PARAM)
' To open a particular WAB file, set the path
' LOCAL szFileName AS ASCIIZ * %MAX_PATH
' szFileName = "<WAB file path>"
' wp.szFileName = VARPTR(szFileName)
' hr = TB_WABOpen(hWABLib, ppIAddrBook, ppIWABObject, wp)
' If we choose not to pass in a WAB_PARAM object,
' the default WAB file will be opened up
hr = TB_WABOpen(hWABLib, ppIAddrBook, ppIWABObject, BYVAL %NULL)
IF hr THEN
MSGBOX "TB_WABOpen - Error: " & HEX$(hr)
EXIT FUNCTION
END IF
' You can think of the WAB as a database. Everything is stored in rows with
' a binary entry identifier (ENTRYID) for each row. In the next portion,
' cbEntryID tells us the size of what the ENTRYID is going to be and
' IAddrBook_GetPAB() will return the entry identifier to our actual
' Address Book data.
hr = IAddrBook_GetPAB(ppIAddrBook, cbEntryID, pEntryID)
IF hr <> %S_OK THEN
MSGBOX "IAddrBook_GetPAB - Error: " & HEX$(hr)
GOTO Terminate
END IF
' Open the Address Book with MAPI_BEST_ACCESS which opens the entry with
' the best available access rights. It returns a pointer to the IABContainer
' interface, which lets us get the contents of the WAB table.
ulObjType = %NULL
ulFlags = %MAPI_BEST_ACCESS
hr = IAddrBook_OpenEntry(ppIAddrBook, cbEntryID, pEntryID, BYVAL %NULL, ulFLags, ulObjType, ppIABContainer)
' Free the buffer pointed by pEntryID
IF ISTRUE pEntryID THEN
IWABObject_FreeBuffer(ppIWABObject, pEntryID)
pEntryID = %NULL
END IF
' Check for IAddrBook_OpenEntry errors
IF hr <> %S_OK THEN
MSGBOX "IAddrBook_OpenEntry - Error: " & HEX$(hr)
GOTO Terminate
END IF
IF ulObjTYpe = %MAPI_ABCONT THEN
' Get the IABTable reference for the WAB
ulFlags = %NULL
hr = IABContainer_GetContentsTable(ppIABContainer, ulFlags, ppIABTable)
IF hr <> %S_OK THEN
MSGBOX "IABContainer_GetContentsTable - Error: " & HEX$(hr)
GOTO Terminate
END IF
hr = IABTable_GetRowCount(ppIABTable, 0, ulRows)
IF hr <> %S_OK THEN
MSGBOX "IABTable_GetRowCount - Error: " & HEX$(hr)
GOTO Terminate
END IF
IF ulRows = 0 THEN
MSGBOX "No rows"
GOTO Terminate
END IF
' Query all the rows
hr = IABTable_QueryRows(ppIABTable, ulRows, 0, dwRowset)
IF hr <> %S_OK THEN
MSGBOX "IABTable_QueryRows - Error: " & HEX$(hr)
GOTO Terminate
END IF
pRowSet = dwRowSet
MSGBOX "pRowSet = " & STR$(pRowSet)
' Get the number of rows retrieved
cRows = @pRowSet.cRows
MSGBOX "Rows = " & STR$(cRows)
' Parse the Rowset array
FOR i = 0 TO cRows - 1
pProp = @pRowSet.aRow(i).lpProps
IF pProp THEN
cValues = @pRowSet.aRow(i).cValues
MSGBOX "cValues = " & STR$(cValues)
FOR x = 0 TO cValues -1
IF @pRowSet.aRow(i).@lpProps[x].ulPropTag = PR_DISPLAY_NAME_A THEN
MSGBOX "Name = " & @pRowSet.aRow(i).@lpProps[x].Value.@lpszA
END IF
IF @pRowSet.aRow(i).@lpProps[x].ulPropTag = PR_EMAIL_ADDRESS_A THEN
MSGBOX "Email = " & @pRowSet.aRow(i).@lpProps[x].Value.@lpszA
END IF
IF @pRowSet.aRow(i).@lpProps[x].ulPropTag = PR_NICKNAME_A THEN
MSGBOX "Email = " & @pRowSet.aRow(i).@lpProps[x].Value.@lpszA
END IF
IF @pRowSet.aRow(i).@lpProps[x].ulPropTag = PR_ENTRYID THEN
cbEntryID = @pRowSet.aRow(i).@lpProps[x].Value.sbin.cb
MSGBOX "cbEntryID = " & STR$(cbEntryID)
pEntryID = @pRowSet.aRow(i).@lpProps[x].Value.sbin.lpb
MSGBOX "pEntryID = " & STR$(pEntryID)
hr = IAddrBook_OpenEntry(ppIAddrBook, cbEntryID, pEntryID, BYVAL %NULL, 0, ulObjType, ppIMailUser)
MSGBOX "ppIMailUser = " & STR$(ppIMailUser) & " | " & HEX$(hr)
' Free the buffer pointed by pEntryID
IF ISTRUE pEntryID THEN
IWABObject_FreeBuffer(ppIWABObject, pEntryID)
pEntryID = %NULL
END IF
IMailUser_Release ppIMailUser
END IF
NEXT
hr = IWABObject_FreeBuffer(ppIWABObject, pProp)
END IF
NEXT
' Free the SRowSet array
hr = IWABObject_FreeBuffer(ppIWABObject, pRowSet)
END IF
Terminate:
' Release the IABTable interface
IF ISTRUE ppIABTable THEN IABTable_Release ppIABTable
' Release the IABContainer interface
IF ISTRUE ppIABContainer THEN IABContainer_Release ppIABContainer
' Release the interfaces
IF ISTRUE ppIAddrBook THEN IAddrBook_Release ppIAddrBook
IF ISTRUE ppIWABObject THEN IWABObject_Release ppIWABObject
' Free the WAB library
IF hWABLib THEN FreeLibrary hWABLib
END FUNCTION
' ****************************************************************************************
|
Page last updated on Monday, 03 April 2006 20:10:57 +0200