Read address book content

Source: Internet
Author: User

// 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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.