0

我制作了一个代码来获取所有联系人,但现在我想获取所有聊天组。如果您从未使用过 Skype4COM API,请不要再阅读本主题。

用于收集所有联系人

    try
    {
        for (int i = 0; i < skype.HardwiredGroups.Count; i++)
            if (skype.HardwiredGroups[i + 1].Type == TGroupType.grpAllFriends)
            {
                for (int j = skype.HardwiredGroups[i + 1].Users.Count; j > 0; j--)
                    listBox1.Items.Add(skype.HardwiredGroups[i + 1].Users[j].Handle);
                button17.Enabled = false;
                break;
            }
    }
    catch (Exception eoi){}

有什么想法可以建立一个组列表吗?

4

1 回答 1

1
private List<string> getChats(Skype skype)
{
    List<string> r = new List<string>();

    foreach (Chat c in skype.Chats)
         try { r.Add(c.Name); } catch (Exception) {}

    return r;
}

我们必须尝试{} catch{},因为 Skype 会生成无效聊天,如果我们尝试访问它们会抛出 COMException。

对于列表框:

foreach (Chat c in skype.Chats) {
     try
     {
         listBox1.Items.Add(c.Name);
     } catch (Exception) {}
}

然后,您可以skype.get_Chat(value)在列表框中的每个项目上使用。

于 2012-04-15T17:23:37.567 回答