【问题标题】:How to retrieve all contacts' details from Windows Contacts programmatically?如何以编程方式从 Windows 联系人中检索所有联系人的详细信息?
【发布时间】:2012-01-31 19:58:13
【问题描述】:

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

【问题讨论】:

  • 请不要在您的标题中添加“(C#, .NET)”之类的内容。这就是标签的用途。

标签: c# .net windows-7 contacts


【解决方案1】:

不要在 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
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-29
    • 1970-01-01
    • 2012-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-20
    • 2012-01-11
    相关资源
    最近更新 更多