我花了很多时间。整个 Skype 论坛似乎已经崩溃或死亡,或者他们没有技术人员来处理这些领域。
入门代码示例不工作或不可用(完全异常)。例如:http://forum.skype.com/index.php?showtopic=3557
因此,我请求有人可以向我展示一个简单的 C# 工作代码示例如何逐步开始。
提前致谢。
最佳答案
- 添加对 skype COM 库的引用
- 添加以下类(class)并开始探索 Skype。
代码(包括 using SKYPE4COMLib;,它搞砸了 stackoverflow 语法高亮显示)
namespace Example
{
class SkypeExample
{
private SkypeClass _skype;
public SkypeExample()
{
_skype = new SkypeClass();
_skype.MessageStatus += OnMessage;
_skype._ISkypeEvents_Event_AttachmentStatus += OnAttach;
_skype.Attach(7, false);
}
private void OnAttach(TAttachmentStatus status)
{
// this app was successfully attached to skype
}
private void OnMessage(ChatMessage pmessage, TChatMessageStatus status)
{
// dont do anything if the message is not received (i.e. we are sending a emssage)
if (status != TChatMessageStatus.cmsReceived)
return;
// simple echo service.
_skype.get_Chat(pmessage.ChatName).SendMessage(pmessage.Body);
}
public bool MakeFriend(string handle)
{
for (int i = 1; i <= _skype.Friends.Count; i++)
{
if (_skype.Friends[i].Handle == handle)
return true;
}
UserCollection collection = _skype.SearchForUsers(handle);
if (collection.Count >= 1)
collection[1].BuddyStatus = TBuddyStatus.budPendingAuthorization;
return false;
}
}
}
关于c# - Skype - 如何开始?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3291090/