Click here to Skip to main content
15,888,579 members
Articles / Programming Languages / C#
Article
Stats
Revisions
.NET1.0
Win2K
WinXP
VS.NET2002
C#
Windows
.NET
Visual-Studio

TAPI 3.0 Application development using C#.NET

devang_bison
Rate me:
Please Sign up or sign in to vote.
4.63/5 (93 votes)
15 Jul 20054 min read 1.6M   44.4K   233   436
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.
  • Download TAPI 3.0 demo project installer - 3.69 MB
  • Download TAPI 3.0 source - 8.7 Kb

Sample Image

Introduction

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.

Background

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 devang.mg@gmail.com.

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:

Image 2

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.

C#
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.
C#
void initializetapi3()
{
    try
    {
        tobj = new TAPIClass();
        tobj.Initialize();
        IEnumAddress ea=tobj.EnumerateAddresses();
        ITAddress ln;
        uint arg3=0;
        lines=0;
    
        cn=new callnotification();
        cn.addtolist=new callnotification.listshow(this.status);
        tobj.ITTAPIEventNotification_Event_Event+= new 
           TAPI3Lib.ITTAPIEventNotification_EventEventHandler(cn.Event);
        tobj.EventFilter=(int)(TAPI_EVENT.TE_CALLNOTIFICATION|
            TAPI_EVENT.TE_DIGITEVENT|
            TAPI_EVENT.TE_PHONEEVENT|
            TAPI_EVENT.TE_CALLSTATE|
            TAPI_EVENT.TE_GENERATEEVENT|
            TAPI_EVENT.TE_GATHERDIGITS|
            TAPI_EVENT.TE_REQUEST);
    
        for(int i=0;i<10;i++)
        {
            ea.Next(1,out ln,ref arg3);
            ia[i]=ln;
            if(ln!=null)
            {
                comboBox1.Items.Add(ia[i].AddressName);
                lines++;
            }
            else
                break;
        }
    }
    catch(Exception e)
    {
        MessageBox.Show(e.ToString());
    }
}

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.

C#
try
{
    registertoken[line]=tobj.RegisterCallNotifications(ia[line],
                 true,true,TapiConstants.TAPIMEDIATYPE_AUDIO,2);    
    MessageBox.Show("Registration token : "+ 
                 registertoken[line], 
                 "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.

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

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:

Image 3

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.

History

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

深圳SEO优化公司太原网站改版推荐长治网站排名优化宣城网站推广多少钱南平关键词按天扣费哪家好吉祥阿里店铺运营报价鞍山模板网站建设焦作网页设计报价丹东网站优化按天扣费亳州模板推广推荐六安网站优化公司延边企业网站建设价格阳江网站开发哪家好益阳建站推荐鹰潭SEO按天收费推荐镇江网站优化软件价格大浪网站搜索优化厦门百度关键词包年推广价格黄冈SEO按效果付费公司固原关键词排名包年推广多少钱黄南网站建设价格湖州优化价格绵阳如何制作网站荷坳百姓网标王哪家好景德镇seo优化公司延安关键词按天计费哪家好抚顺企业网站制作多少钱霍邱网站制作报价南平网站建设设计价格邢台网站搭建价格海西百姓网标王公司歼20紧急升空逼退外机英媒称团队夜以继日筹划王妃复出草木蔓发 春山在望成都发生巨响 当地回应60岁老人炒菠菜未焯水致肾病恶化男子涉嫌走私被判11年却一天牢没坐劳斯莱斯右转逼停直行车网传落水者说“没让你救”系谣言广东通报13岁男孩性侵女童不予立案贵州小伙回应在美国卖三蹦子火了淀粉肠小王子日销售额涨超10倍有个姐真把千机伞做出来了近3万元金手镯仅含足金十克呼北高速交通事故已致14人死亡杨洋拄拐现身医院国产伟哥去年销售近13亿男子给前妻转账 现任妻子起诉要回新基金只募集到26元还是员工自购男孩疑遭霸凌 家长讨说法被踢出群充个话费竟沦为间接洗钱工具新的一天从800个哈欠开始单亲妈妈陷入热恋 14岁儿子报警#春分立蛋大挑战#中国投资客涌入日本东京买房两大学生合买彩票中奖一人不认账新加坡主帅:唯一目标击败中国队月嫂回应掌掴婴儿是在赶虫子19岁小伙救下5人后溺亡 多方发声清明节放假3天调休1天张家界的山上“长”满了韩国人?开封王婆为何火了主播靠辱骂母亲走红被批捕封号代拍被何赛飞拿着魔杖追着打阿根廷将发行1万与2万面值的纸币库克现身上海为江西彩礼“减负”的“试婚人”因自嘲式简历走红的教授更新简介殡仪馆花卉高于市场价3倍还重复用网友称在豆瓣酱里吃出老鼠头315晚会后胖东来又人满为患了网友建议重庆地铁不准乘客携带菜筐特朗普谈“凯特王妃P图照”罗斯否认插足凯特王妃婚姻青海通报栏杆断裂小学生跌落住进ICU恒大被罚41.75亿到底怎么缴湖南一县政协主席疑涉刑案被控制茶百道就改标签日期致歉王树国3次鞠躬告别西交大师生张立群任西安交通大学校长杨倩无缘巴黎奥运

深圳SEO优化公司 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化

License

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


Written By
devang_bison
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 b.tech(i.t.) degree at Nirma Institute of Technology,Gujarat(india).
Skills : vb.net,vc#.net,VC++(MFC)

Comments and Discussions

 
Question It is not displaying my service provider in the list Pin
Mahadevan Venkatesan2-Oct-19 19:52
Mahadevan Venkatesan2-Oct-19 19:52 
Question what is Proper hardware for this code Pin
aref_it6-Sep-19 21:41
aref_it6-Sep-19 21:41 
Question TAPI 3.0 Application development using C#.NET Pin
Member 1435936613-May-19 19:12
Member 1435936613-May-19 19:12 
Question Couldn't register for any line of communication Pin
Member 137524694-Apr-18 1:48
Member 137524694-Apr-18 1:48 
Question can you able to take project? Pin
Member 134402441-Oct-17 18:41
Member 134402441-Oct-17 18:41 
Question Can i use this code with GSM Modem? If Yes Please share Modify Code. Pin
Member 1337933328-Aug-17 3:55
Member 1337933328-Aug-17 3:55 
Question Call recording using TAPI Pin
nitin-aem26-Jul-17 0:22
nitin-aem26-Jul-17 0:22 
Question Tapi don't sometimes answer or reject calls Pin
amagitech6-Apr-17 0:25
amagitech6-Apr-17 0:25 
Answer Re: Tapi don't sometimes answer or reject calls Pin
Member 1320383116-May-17 2:15
Member 1320383116-May-17 2:15 
Question Getting following error on listbox Pin
Member 129875147-Feb-17 4:58
Member 129875147-Feb-17 4:58 
Question How to transfer call from AddTapi.net in c# ?? Pin
Jignesh Patel 428225-Nov-16 0:08
Jignesh Patel 428225-Nov-16 0:08 
Question How to GetCallInformation and Transfer call In addtapi.net with asp.net c# ? Pin
Jignesh Patel 42827-Nov-16 0:19
Jignesh Patel 42827-Nov-16 0:19 
Question Development Environment Pin
pæperclip2-Aug-16 4:45
pæperclip2-Aug-16 4:45 
Question Not able to fetch callerid Pin
sarath1er20-Jun-16 20:05
sarath1er20-Jun-16 20:05 
Question register failed values Pin
Pradeep Kadnor14-Nov-15 8:45
Pradeep Kadnor14-Nov-15 8:45 
Answer Re: register failed values Pin
Member 1291214919-Dec-16 4:23
Member 1291214919-Dec-16 4:23 
Question RegisterCallNotifications(..) and SetQOS(..) always failed Pin
zxmlxclyj23-Oct-15 10:36
zxmlxclyj23-Oct-15 10:36 
Question got exception button2_click Pin
okansarica5-Aug-15 22:07
okansarica5-Aug-15 22:07 
Question does not work with win 7 or 8 Pin
Member 1152549214-Mar-15 14:28
Member 1152549214-Mar-15 14:28 
Answer Re: does not work with win 7 or 8 Pin
Naveed Yousaf13-May-15 23:50
professional Naveed Yousaf13-May-15 23:50 
General Re: does not work with win 7 or 8 Pin
Pratik19Chaudhari27-Nov-15 19:30
Pratik19Chaudhari27-Nov-15 19:30 
Question Event Forwarding Pin
Member 1124369018-Nov-14 2:34
Member 1124369018-Nov-14 2:34 
Question how can register H323 protocol in window7 os and use with tapi3.0 in c#? Pin
upendra205865-Oct-14 18:37
upendra205865-Oct-14 18:37 
Answer Re: how can register H323 protocol in window7 os and use with tapi3.0 in c#? Pin
upendra205865-Oct-14 18:41
upendra205865-Oct-14 18:41 
Question Problem Pin
g@urav12328-Aug-14 2:04
g@urav12328-Aug-14 2:04 

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.


深圳SEO优化公司太原网站改版推荐长治网站排名优化宣城网站推广多少钱南平关键词按天扣费哪家好吉祥阿里店铺运营报价鞍山模板网站建设焦作网页设计报价丹东网站优化按天扣费亳州模板推广推荐六安网站优化公司延边企业网站建设价格阳江网站开发哪家好益阳建站推荐鹰潭SEO按天收费推荐镇江网站优化软件价格大浪网站搜索优化厦门百度关键词包年推广价格黄冈SEO按效果付费公司固原关键词排名包年推广多少钱黄南网站建设价格湖州优化价格绵阳如何制作网站荷坳百姓网标王哪家好景德镇seo优化公司延安关键词按天计费哪家好抚顺企业网站制作多少钱霍邱网站制作报价南平网站建设设计价格邢台网站搭建价格海西百姓网标王公司歼20紧急升空逼退外机英媒称团队夜以继日筹划王妃复出草木蔓发 春山在望成都发生巨响 当地回应60岁老人炒菠菜未焯水致肾病恶化男子涉嫌走私被判11年却一天牢没坐劳斯莱斯右转逼停直行车网传落水者说“没让你救”系谣言广东通报13岁男孩性侵女童不予立案贵州小伙回应在美国卖三蹦子火了淀粉肠小王子日销售额涨超10倍有个姐真把千机伞做出来了近3万元金手镯仅含足金十克呼北高速交通事故已致14人死亡杨洋拄拐现身医院国产伟哥去年销售近13亿男子给前妻转账 现任妻子起诉要回新基金只募集到26元还是员工自购男孩疑遭霸凌 家长讨说法被踢出群充个话费竟沦为间接洗钱工具新的一天从800个哈欠开始单亲妈妈陷入热恋 14岁儿子报警#春分立蛋大挑战#中国投资客涌入日本东京买房两大学生合买彩票中奖一人不认账新加坡主帅:唯一目标击败中国队月嫂回应掌掴婴儿是在赶虫子19岁小伙救下5人后溺亡 多方发声清明节放假3天调休1天张家界的山上“长”满了韩国人?开封王婆为何火了主播靠辱骂母亲走红被批捕封号代拍被何赛飞拿着魔杖追着打阿根廷将发行1万与2万面值的纸币库克现身上海为江西彩礼“减负”的“试婚人”因自嘲式简历走红的教授更新简介殡仪馆花卉高于市场价3倍还重复用网友称在豆瓣酱里吃出老鼠头315晚会后胖东来又人满为患了网友建议重庆地铁不准乘客携带菜筐特朗普谈“凯特王妃P图照”罗斯否认插足凯特王妃婚姻青海通报栏杆断裂小学生跌落住进ICU恒大被罚41.75亿到底怎么缴湖南一县政协主席疑涉刑案被控制茶百道就改标签日期致歉王树国3次鞠躬告别西交大师生张立群任西安交通大学校长杨倩无缘巴黎奥运

深圳SEO优化公司 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化