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

标签 c# .net windows-7 contacts

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

最佳答案

请勿在 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
}

关于c# - 如何以编程方式从 Windows 联系人中检索所有联系人的详细信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9086029/

相关文章:

c# - 使用 JSON.NET 的序列化字段的顺序

c# - 按创建顺序对哈希表进行排序

Windows 7 SCardGetStatusChange 中的 C++ 源代码返回代码 6

.net - 在 Windows 7 多点触控上按下 WPF 按钮

c# - Azure服务总线消息重新出现超时

c# - 如何在 C# 中合并/提取重复的代码结构

.net - 如何使用 AES 加密单个 block ?

c#检查文件路径是否包含特定目录

c# - 如何为 Windows 7/8 实现自动播放

C# 将多个参数传递给 BAT 文件