title: Call Monitor using C# TAPI
body: <p>I need to create a program to monitor activity of phone call.And get information about the calls, like number and Name. 
  I'm not strong with TAPI code and C#, so hope that anybody can help me, I'm desperate.</p>
  
  <p>I have this code where I try to detect the available devices and obtain information from those devices when a call comes in:</p>
  
  <pre><code>using System;
  using TAPI3Lib; 
  using JulMar.Atapi; 
  
  namespace ConsoleApp1
  {
    class Program
    {
      private void tapi_ITTAPIEventNotification_Event(TAPI_EVENT TapiEvent, object pEvent)
      {
          try
          {
              ITCallNotificationEvent cn = pEvent as ITCallNotificationEvent;
              if(cn.Call.CallState == CALL_STATE.CS_CONNECTED)
              {
                  string calledidname = cn.Call.get_CallInfoString(CALLINFO_STRING.CIS_CALLEDIDNAME);
                  Console.WriteLine("Called ID Name " + calledidname);
                  string callednumber = cn.Call.get_CallInfoString(CALLINFO_STRING.CIS_CALLEDIDNUMBER);
                  Console.WriteLine("Called Number " + callednumber);
                  string calleridname = cn.Call.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNAME);
                  Console.WriteLine("Caller ID Name " + calleridname);
                  string callernumber = cn.Call.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER);
                  Console.WriteLine("Caller Number " + callernumber);
  
  
              }
          }
          catch(Exception ex)
          {
              Console.WriteLine(ex.ToString());
          }
      }
  
  
  
      static void Main(string[] args)
      {
          TapiManager mgr = new TapiManager("ConsoleApp1");
          mgr.Initialize();
  
          foreach(TapiLine line in mgr.Lines)
          {
              foreach (string s in line.Capabilities.AvailableDeviceClasses)
                  Console.WriteLine("{0} - {1}", line.Name, s);
          }
      }
  }
  }
  </code></pre>
  
  <p>But when I run it, just see the available devices but don't see any information about calls. I'm used to programming in java so I guess I should send to call the method that gets the call information in the main, but I do not know how to do that and in any code I've seen they do.
  So, hope that you can help me to understand how TAPI works and what can I do to do my code work.</p>