我有一个应用程序,我希望用 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/