Some days ago i finished a project which was about using the TAPI. I will give you a short introduction into TAPI and give my example for that project.
Here a short description about what TAPI is.
The Telephony Application Programming Interface (TAPI) is a Microsoft Windows API, which provides computer telephony integration and enables PCs running Microsoft Windows to use telephone services.
With it you can control a telephone which uses this TAPI. You can listen for calls, make calls and many other things.
For this project I only needed to make a call by clicking on a number in the browser, of course it should work in every browser.
First of all we will check how to get the number from the browser to the telephone. A client has installed the telephone so we need a client solution. So what can we do on the client to pass a number as parameter via TAPI to a telephone? Probably via desktop command line application which is using the TAPI-Library.
Okay now we know how will communicate with the telephone, but how will that application get the number from browser?
How can we register such a protocol now?
I don’t know how to do that on UNIX Systems but on Windows we just need a registry entry!
By replacing the PROTOCOL_NAME with your own protocol and the PATH_TO_EXE with the absolute path to your exe file you can pass parameters to the program.
The %1 is for a parameter, you will get that parameter through the arguments in the main method.
I have made a batch file which installs the the whole thing…
copy Interop.TAPI3Lib.dll “C:\TAPI”
copy TapiCall.exe “C:\TAPI”
This batch file creates the directory TAPI on C: and copies the files which are needed and finally executes the regedit file.
Now we just need the program which sends the number to the TAPI-Device.
I decided to use C# because I found a TAPI Library for C# and of course because I know C# really good.
It is easy to make programs with C#, you can be really fast and the community is really big.
I used an example from Codeprojects to test the dialing process and the final solution look like that…
Here you can see the main method which takes the main parameters and parses it.
Don’t forget to include the TAPI-Library.
Finally the call method which takes the number as string. Here i use the line which name contains “Agfeo” because the TAPI devices are from Agfeo.
When you click on a link now which has the value phone:123456 in the href attribute the program sends the number 123456 to the TAPI device to and starts the call.
This is a browser independent solution of using your own protocol on a windows machine via browsers.
I hope this helped you a bit if you try to make something like that.
The Visual Studio Project is in the source files which you can download here.