Search code examples
c#.netvb.netwinformstapi

How to make caller id in c#.net



I know this is answered question however I want to know hardware required and how to setup.

I am trying to build a take-out's delivery system wherein users call and their phone number gets captured on a WINFORM.

I googled and it says I need to use TAPI API. That's fine but do I need to connect anything to the PC or will just using TAPI work?

This Link explains it in VB.net. I am looking for it in c#.net. I have also gone through the links provided here.

But nowhere does it explain the setup. So please help.


Solution

  • First thing

    • See if your hardware supports caller ID
    • Add the serial port control, set it to whatever comm port your modem is on and watch for the CALLER ID number, then react

    To see if your modem supports Caller ID open a serial port terminal (I like putty) and set it to the com port of your modem then call the phone number attached to that that modem, you should see something like RING 5555555555 (where 5555555555 is the phone number of the person calling you)

    You may have to turn caller id on for that modem (if so)

    1) Open the "Phone And Modem Options" control panel

    2) Click the "Modems" tab

    3) Select your modem in the list (if it is not already selected)

    4) Click the "Properties" button

    5) Click the "Advanced" tab

    6) Type "#CID=1" into the "Extra initialization commands" edit box Note: replace "#CID=1" with the command to enable caller id on your modem Do not include the "AT" part of the command Do not include the quotes 7) Click OK

    8) Click OK

    9) restart the computer

    Here is some code for interacting with a serial port in c# (incase you need that)

    public SerialPort sp;
    string dataReceived = string.Empty;
    private delegate void SetTextDeleg(string text);
    
    private void FormLoad()
    {
     sp = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
     this.sp.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived);
     sp.Open();
    }
    
    void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {
     try
     {
          Thread.Sleep(500);
           string x = sp.ReadLine(); // will read to the first carriage return
           this.BeginInvoke(new SetTextDeleg(si_DataReceived), new object[] { x });
      }
      catch
      { }
    }  
    
    private void si_DataReceived(string data)
    {
      dataReceived = data.Trim();
    
      // Do whatever with the data that is coming in.
    }
    

    Also I just searched amazon for "Caller ID Modem" and there seem to be alot for between 10 and 20 dollars (US) that support this exact use. I would recommend the Trendnet TFM-561U