// Main. h
# Include <windows. h>
# Include <crtdbg. h>
# Include <iostream. h>
# Include <wab. h>
Typedef hresult (winapi * fwabopen) (lpadrbook *, lpwabobject *, lpwab_param, DWORD );
Int main ()
{
Hresult hres;
Lpadrbook;
Lpwabobject;
Lpwab_param lpwabparam = NULL;
DWORD reserved2 = NULL;
Hinstance hinstlib;
Hinstlib = loadlibrary ("C: \ Program Files \ common files \ System \ wab32 ");
Fwabopen procwabopen;
If (hinstlib! = NULL)
{
Procwabopen = (fwabopen) getprocaddress (hinstlib, "wabopen ");
If (procwabopen! = NULL)
{
Hres = (procwabopen) (& lpadrbook, & lpwabobject, null, reserved2 );
_ Asserte (hres = s_ OK );
If (hres! = S_ OK) Exit (1 );
// Lpwabobject-> Find (lpadrbook, null );
Ulong lpcbentryid;
Entryid * lpentryid;
Hres = lpadrbook-> getpab (
& Amp; lpcbentryid,
& Lpentryid
);
_ Asserte (hres = s_ OK );
If (hres! = S_ OK) Exit (2 );
Ulong ulflags = mapi_best_access;
Ulong ulobjtype = NULL;
Lpunknown lpunk = NULL;
Hres = lpadrbook-> openentry (
Lpcbentryid,
Lpentryid,
Null,
Ulflags,
& Ulobjtype,
& Lpunk
);
Ulflags = NULL;
// Iabtable * lptable;
If (ulobjtype = mapi_abcont)
{
Iabcontainer * lpcontainer = static_cast <iabcontainer *> (lpunk );
Lpmapitable lptable = NULL;
Hres = lpcontainer-> getcontentstable (
Ulflags,
& Lptable
);
_ Assert (lptable );
Ulong ulrows;
Hres = lptable-> getrowcount (0, & ulrows );
_ Asserte (hres = s_ OK );
Cout <"rows" <ulrows <Endl;
Srowset * lprows;
Hres = lptable-> queryrows (
Ulrows, // get all rows
0,
& Lprows
);
For (ulong I = 0; I <lprows-> crows; I ++)
{
Srow * lprow = & lprows-> Arow [I];
Cout <I <":" <lprow-> cvalues <Endl;
For (ulong J = 0; j <lprow-> cvalues; j ++)
{
Spropvalue * lpprop = & lprow-> lpprops [J];
Cout <"\ t" <j <":" <(void *) lpprop-> ulproptag <":";
If (lpprop-> ulproptag = pr_display_name_a)
Cout <"display name:" <lpprop-> value. lpsza;
If (lpprop-> ulproptag = pr_email_address_a)
Cout <"email address:" <lpprop-> value. lpsza;
If (lpprop-> ulproptag = pr_nickname_a)
Cout <"nickname:" <lpprop-> value. lpsza;
If (lpprop-> ulproptag = pr_addrtype_a)
Cout <"addrtype:" <lpprop-> value. lpsza;
Cout <Endl;
}
Lpwabobject-> freebuffer (lprow );
}
Lpwabobject-> freebuffer (lprows );
}
}
Freelibrary (hinstlib );
}
Return 0;
}