Register incomming Skype calls with ActiveS in C# .NET

Description of the problem – register incomming Skype calls

Skype allows you to register for incomming calls – you can decide if you wanna take the call or not. ActiveS is a wrapper that allows you to control Skype through an easy API.

Solution: register incomming Skype calls ( C# and .NET )

The solution for Visual Basic is similar.

try {
// initialize Skype / ActiveS
ConversionClass m_objConversion = new ConversionClass();
AccessClass m_objAccess = new AccessClass();
// register event handler that listens on status changes of calls
m_objAccess.CallStatusChanged += new _IAccessEvents_CallStatusChangedEventHandler(Skype_CallStatusChanged);
// connect to Skype
m_objAccess.Connect();
} catch (Exception e) {
Console.WriteLine(e.Message);
}

// our event handler
void Skype_CallStatusChanged(SKYPEAPILib.Call call, SKYPEAPILib.SkypeCallProgress callProgress)
{
if (callProgress.Equals(SKYPEAPILib.SkypeCallProgress.prgRinging) && call.Type.Equals(SkypeCallType.ctypIncomingP2P))
{
// display message box to ask user
MessageBox.Show("Do you wanna take that call from " + call.PartnerDisplayName + "?",
"Incomming Skype-call from " + call.PartnerDisplayName,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);

// if user answered no, hang up call
if(res.Equals(DialogResult.No))
{
call.Status = SKYPEAPILib.SkypeCallProgress.prgFinished;
}
else
{
call.Status = SKYPEAPILib.SkypeCallProgress.prgInProgress;
}
}
}