如何以编程方式从Windows联系人中检索所有联系人的详细信息?

时间:2012-01-31 19:58:14

标签: c# .net windows-7 contacts

我有一个应用程序,其中我希望我的控件(可能是列表框)填充Windows联系人(存在于Windows 7中)中的联系人姓名和号码。这怎么可能?

1 个答案:

答案 0 :(得分:3)

不要在Windows 7中使用此功能。它是在Vista中引入的,很快就在Windows Server 2008中被弃用。

无论如何,here is the entrance to C++ API section (that also explains the Contacts schema) at MSDN

但是对于托管代码,您应该使用Contacts.Net项目here at codeplex。这是一个枚举联系人的简单示例:

//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
}
相关问题