Opening and Closing Address Book

You must call abOpen before you can use other functions. Pass it a pointer to IfmManage. The following code example shows how to get the interface pointer, and how to open and close Address Book.

#include <asfc.h>
#include <abapi.h>

// . . .

IfmManage        *pFMM;        // The Forms Manager object
HRESULT             hr;            // A result handle
hr = CoCreateInstance(CLSID_FMMANAGE, NULL, CLSCTX_INPROC_SERVER,
                        IID_FMMANAGE, (PVOID *) &pFMM);
if (FAILED(hr)) {
        return E_FAIL ; // 
}

abOpen(pFMM); // Open the Contacts database using the Address Book API.

// . . . You can call other Address Book API functions now.

abClose(); // Close the Contacts database using the Address Book API.

return S_OK ;