Reputation: 644
I have an application in which I want my control (maybe listbox) to be populated with the contact's name and number present in the Windows Contacts (present in Windows 7). How is this possible?
Upvotes: 2
Views: 1819
Reputation: 4137
Do not use this feature in Windows 7. It was introduced in Vista and soon got deprecated in Windows Server 2008.
Any way, here is the entrance to C++ API section (that also explains the Contacts schema) at MSDN.
But for managed code, you should use the Contacts.Net project here at codeplex. Here is a simple example that enumerates contacts:
//using Microsoft.Communications.Contacts;
ContactManager theContactManager = new ContactManager();
foreach (Contact theContact in theContactManager.GetContactCollection())
{
string theLine = theContact.Names[0].FormattedName;
foreach(PhoneNumber theNumber in theContact.PhoneNumbers)
theLine += "\t" + theNumber.ToString();
listBox1.Items.Add(theLine);
//Console.WriteLine(theLine); //Uncomment this if on console
}
Upvotes: 3