Click here to Skip to main content
13,258,269 members (50,455 online)
Click here to Skip to main content
Add your own
alternative version


228 bookmarked
Posted 15 Jul 2005

TAPI 3.0 Application development using C#.NET

, 15 Jul 2005
Rate this:
Please Sign up or sign in to vote.
This is a sample telephony application which will help you to develop applications using TAPI 3.0 API and C#.NET. Here basic knowledge about TAPI is assumed.

Sample Image


This is a C# program which will exemplify the procedure which needs to be followed while doing TAPI programming using TAPI 3.0. Hence it can also be useful for VB.NET developers seeking TAPI 3.0 sample code for .NET. Here basic knowledge about TAPI and other related terms is assumed. To have more knowledge on TAPI 3.0, contact me on my email address or refer to the help provided in MSDN.


Hello, myself Gohel Devang M., 20 years old, Information Technology student. This is my first attempt to put some sample code on any site so if you do have any problems mail me at

This is a sample code to interface TAPI 3.0 API using .NET platform and C# as language. So people interested in developing telephony applications using C# will find this very useful. I was inspired to do this because I was not able to find such code on this site.

Initial steps

The first thing you need to start working on TAPI 3.0 API is to add the references to your project. To do that first create a new project or open an existing project, then right click on the solution file in Solution Explorer. This will open a dialog box showing three tabs as below:

Then click on Browse button and select the tapi3.dll file from your windows\system32 or windows\system directory and click OK. Then press OK in the dialog box that had popped when you select Add references from the right click popup menu of the Solution Explorer.

Now you are ready to work with TAPI 3.0.

Using the code

The second thing you need to do is create the TAPI objects to initialize the TAPI 3.0 TSP (TAPI Service Providers). To have more information on TSP and what TAPI is all about, please refer to help provided in the MSDN .NET documentation. The code below is a declaration of the TAPI object and addresses the interfaces that will hold the addresses which are responsible for call handling, and basic call control interface which will hold the reference to the object that will be responsible for handling basic operations of the call.

private TAPIClass tobj;
private ITAddress[] ia=new TAPI3Lib.ITAddress[10];
private ITBasicCallControl bcc;

The code below is responsible for initializing a TAPI object so that it can be used by our application. The main functions are:

  • Initialize() will initialize TAPI.
  • EnumerateAddresses() will give the list of available TSPs.
void initializetapi3()
        tobj = new TAPIClass();
        IEnumAddress ea=tobj.EnumerateAddresses();
        ITAddress ln;
        uint arg3=0;
        cn=new callnotification();
        cn.addtolist=new callnotification.listshow(this.status);
        tobj.ITTAPIEventNotification_Event_Event+= new 
        for(int i=0;i<10;i++)
            ea.Next(1,out ln,ref arg3);
    catch(Exception e)

The code below is responsible for registering incoming calls so that they can be handled by our application. For that you need to select the line on which you want to receive calls and press the Register button.

    MessageBox.Show("Registration token : "+ 
                 "Registration Succeed for line "+line);
catch(Exception ein)
    MessageBox.Show("Failed to register on line "+line,"Registration for calls");

The class given below is to be added depending upon your TAPI event handling requirements. This is specially designed according to the requirements of the application.

class callnotification:TAPI3Lib.ITTAPIEventNotification
    public delegate void listshow(string str);
    public listshow addtolist;
    public void Event(TAPI3Lib.TAPI_EVENT te,object eobj)
                addtolist("call notification event has occured");
                TAPI3Lib.ITDigitDetectionEvent dd = 
                addtolist("Dialed digit"+dd.ToString());
                TAPI3Lib.ITDigitGenerationEvent dg = 
                MessageBox.Show("digit dialed!");
                addtolist("Dialed digit"+dg.ToString());
                addtolist("A phone event!");
                addtolist("Gather digit event!");
            case TAPI3Lib.TAPI_EVENT.TE_CALLSTATE:
                TAPI3Lib.ITCallStateEvent a= 
                TAPI3Lib.ITCallInfo b=a.Call;
                case TAPI3Lib.CALL_STATE.CS_INPROGRESS:
                case TAPI3Lib.CALL_STATE.CS_CONNECTED:
                case TAPI3Lib.CALL_STATE.CS_DISCONNECTED:
                case TAPI3Lib.CALL_STATE.CS_OFFERING:
                    addtolist("A party wants to communicate with you!");
                case TAPI3Lib.CALL_STATE.CS_IDLE:
                    addtolist("Call is created!");

How to handle H.323 or IP calls?

To do IP calls or H.323 calls, you need to make a checkbox named H.323 call(IP call) enabled and enter the IP address of the destination and press the Call button. Otherwise it will not succeed in calling to the remote destination. To receive H.323 calls or IP calls, you need to first register on the line on which you want to receive IP calls and check the checkbox named h.323 call(IP call).

How to answer an incoming call

The incoming calls will give notification in the call status area. Then according to whether you want to accept or reject the call, you check the checkbox named Reject to reject incoming calls, and press Answer or simply press Disconnect. To accept calls, do not check Reject checkbox and simply press Answer button which will connect to the call.

How to transfer a call

To transfer a call, first there should be one active call existing. Then you can specify the address to which the call is to be transferred to, as shown in the figure:

Here I have specified the internet address since the call was an IP call. To provide this functionality, there is one function in IBasicCallControl named BlindTransfer(String transfferaddress). Refer the MSDN documents for more information on that!

Points of Interest

My interest is in developing more and more TAPI 3.0 applications using .NET as the platform. I am also interested in J2EE application development. My other areas of interest are:

  • VC++
  • Crystal Reports

and many other thing in my reach.


Latest revised version. This is the first release of this code so if you do have any suggestions they are always welcomed by me.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
India India
Hi,I am 21 year old student of information technology.I am interested to develop Computer telephony integeration softwares. I am also interested in deploying crystal reports, Directx programming and device driver implementation using VC++.Currently i am pursuing my degree at Nirma Institute of Technology,Gujarat(india).
Skills :,,VC++(MFC)

You may also be interested in...


Comments and Discussions

QuestionHow the SSTP/PPTP/L2TP will work? Pin
Member 1001650928-Apr-13 21:01
memberMember 1001650928-Apr-13 21:01 
QuestionNeed Testing Steps Pin
Amjad_pk27-Mar-13 4:26
memberAmjad_pk27-Mar-13 4:26 
QuestionGetting Same Error Pin
Chintan Dalwadi7-Feb-13 21:29
memberChintan Dalwadi7-Feb-13 21:29 
AnswerRe: Getting Same Error Pin
farzad zaheri27-Mar-13 4:58
memberfarzad zaheri27-Mar-13 4:58 
AnswerRe: Getting Same Error Pin
Dhruv Shah00719-Aug-13 8:52
memberDhruv Shah00719-Aug-13 8:52 
QuestionHow to detect Caller Id using TAPI? Pin
Sabah u Din Irfan4-Feb-13 5:23
memberSabah u Din Irfan4-Feb-13 5:23 
GeneralMy vote of 4 Pin
WeylandYutani9-Dec-12 21:18
memberWeylandYutani9-Dec-12 21:18 
QuestionWindows 8 Pin
Easygoing19-Nov-12 1:38
memberEasygoing19-Nov-12 1:38 

is this running under windows8? I tried you examplte, but the line for my Telephone-System is not found. Under Windwos 7 it's fine!

Any ideas?

Best Regards
QuestionRe: Windows 8 Pin
afaz12-Jan-13 19:27
memberafaz12-Jan-13 19:27 
QuestionCaller ID Pin
Member 844370130-Oct-12 15:58
memberMember 844370130-Oct-12 15:58 
AnswerRe: Caller ID Pin
Easygoing19-Nov-12 1:39
memberEasygoing19-Nov-12 1:39 
Questionincoming call? Pin
Easygoing15-Oct-12 0:26
memberEasygoing15-Oct-12 0:26 
Questionwhen i try to install and done.... Pin
csharpcomeintome20-Sep-12 22:33
membercsharpcomeintome20-Sep-12 22:33 
AnswerRe: when i try to install and done.... Pin
HassanMirza1-Dec-12 9:26
memberHassanMirza1-Dec-12 9:26 
Bugand then its.... Pin
csharpcomeintome20-Sep-12 5:09
membercsharpcomeintome20-Sep-12 5:09 
Bughe's not reply! Pin
csharpcomeintome20-Sep-12 5:08
membercsharpcomeintome20-Sep-12 5:08 
QuestionHRESULT 0x80040007 OLE_E_BLANK Pin
dnyan8613-Sep-12 4:22
memberdnyan8613-Sep-12 4:22 
QuestionNot work!! Pin
CrisLoveStefy2-Sep-12 22:22
memberCrisLoveStefy2-Sep-12 22:22 
AnswerRe: Not work!! Pin
CrisLoveStefy18-Sep-12 4:00
memberCrisLoveStefy18-Sep-12 4:00 
QuestionDTMF digits not detected Pin
Rinaldo Bonfanti Posta7-Aug-12 5:49
memberRinaldo Bonfanti Posta7-Aug-12 5:49 
Question"Com Excepiton " Please help me..... Pin
Avadhut Salavi10-May-12 0:15
memberAvadhut Salavi10-May-12 0:15 
QuestionTapi aplication, problem with sending DTMF signal Pin
Member 86346749-Feb-12 9:18
memberMember 86346749-Feb-12 9:18 
GeneralMy vote of 5 Pin
emmybest1-Feb-12 7:06
memberemmybest1-Feb-12 7:06 
BugApplication fail to register after some time Pin
saadullah Bhutto29-Sep-11 6:21
membersaadullah Bhutto29-Sep-11 6:21 
QuestionTAPI 3 on windows 7 Pin
Member 809297018-Jul-11 5:10
memberMember 809297018-Jul-11 5:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171114.1 | Last Updated 15 Jul 2005
Article Copyright 2005 by devang_bison
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid