|
About 20 years ... since Microsoft introduced WOSA (Windows Open Service Architecture) including TAPI.
Since then there is no single fully implemeted OCX or something similar available.
Since then developers searching the internet for just one single working sample code in VB.
THIS sample here (by Bishoy Ghaly) ... I put my hope on.
In VB 2008 the code is running (after some little modifications) but no event is fired.
Does Microsoft know how many weeks a developer has to invest to get a simply app (like showing a callerID) up and running?
If this will ever work on this extremely bad documented API?
I dont know what to do know and if there is a single example for a working TAPI project (written in Visual Basic 2008/.NET 3.5), please let me know and I will be thankful for the rest of my life.
Cheers
Tom
|
|
|
|
|
Hi Tom, I can feel your frustration, however you should know that TAPI was not designed to be used from .net or managed stack, it is best to use it from old VB or even C++ if possible if you need to use most of its features.
the main reason for this is that .net creates an Interop for TAPI ocx that cannot support some of COM features and its deep polymorphism.
if you used my sample code here as basis for your implementation, maybe I can help you if you have specific questions or need help in performing specific task, simply post your questions here or you can find my on skype with id="bghaly""Imagination is more important than knowledge.."
{Albert Einstein}
|
|
|
|
|
Bishoy,
thanks for your note.
Here is my code .... everything is working fine but no event is fired:
First a little form:
Public Class Form2
Private WithEvents TAPI As Klassendesign.itsTAPI
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim myTAPI As New Klassendesign.itsTAPI
TAPI = myTAPI
End Sub
Private Sub TAPI_tapiEvent(ByVal TapiEvent As TAPI3Lib.TAPI_EVENT, ByVal pEvent As Object) Handles TAPI.tapiEvent
Stop
End Sub
End Class
And then my class
Imports TAPI3Lib
Namespace Klassendesign
Public Class itsTAPI
Private Const MediaAudio As Integer = 8
Private Const MediaModem As Integer = 16
Private Const MediaFax As Integer = 32
Private Const MediaVideo As Integer = 32768
Private WithEvents oTAPI As TAPI3Lib.TAPI ' will hold our TAPI object
Private oAddress As ITAddress ' will hold our selected address (you can hold many address in an array)
Private RegCookie As Integer
Private Const TAPI3_ALL_TAPI_EVENTS = _
TAPI_EVENT.TE_ACDGROUP Or _
TAPI_EVENT.TE_ADDRESS Or _
TAPI_EVENT.TE_AGENT Or _
TAPI_EVENT.TE_AGENTHANDLER Or _
TAPI_EVENT.TE_AGENTSESSION Or _
TAPI_EVENT.TE_CALLHUB Or _
TAPI_EVENT.TE_CALLINFOCHANGE Or _
TAPI_EVENT.TE_CALLMEDIA Or _
TAPI_EVENT.TE_CALLNOTIFICATION Or _
TAPI_EVENT.TE_CALLSTATE Or _
TAPI_EVENT.TE_DIGITEVENT Or _
TAPI_EVENT.TE_GENERATEEVENT Or _
TAPI_EVENT.TE_PRIVATE Or _
TAPI_EVENT.TE_QOSEVENT Or _
TAPI_EVENT.TE_QUEUE Or _
TAPI_EVENT.TE_REQUEST Or _
TAPI_EVENT.TE_TAPIOBJECT
Sub New()
Try
' creating a new instance to first initialize TAPI befor attaching the events
Dim m_TAPI As New TAPIClass
' a variable to hold supported media types for the address
Dim MediaTypes As Integer
' initializing TAPI
m_TAPI.Initialize()
' attaching event sink
oTAPI = m_TAPI
' getting red of the private instance as we have another global instance (oTAPI)
m_TAPI = Nothing
Dim AddressCollection As ITCollection = oTAPI.Addresses()
For Each Address As ITAddress In AddressCollection ' looping through address collection
'(following line just take my wanted tapi provider)
If Address.AddressName = "AVM TAPI Services for FRITZ!Box" Then
If Address.State = ADDRESS_STATE.AS_INSERVICE Then ' checking if address is working
Dim MediaSupport As ITMediaSupport = Address ' extracting meida support interface from the address
MediaTypes = MediaSupport.MediaTypes ' extracting media types supporting
MediaSupport = Nothing ' dispose of the object
'If (MediaTypes And MediaModem) = MediaModem Then
' the address is a data Modem
If (MediaTypes And MediaAudio) = MediaAudio Then
' Select the address since it supports Audio and is a FAX/Modem
oAddress = Address ' select this address
MsgBox("we have selected this address: " + oAddress.AddressName) ' show the selected address name
Exit For
' End If
End If
End If
End If
Next Address
If Not (oAddress Is Nothing) Then
' registering notifications for the selected address
RegCookie = oTAPI.RegisterCallNotifications(oAddress, True, False, MediaTypes, 1)
' Note: this registration can be done on as many adresses as you want
' we will not receive notifications unless we spacify which type of events we are interested in
oTAPI.EventFilter = TAPI3_ALL_TAPI_EVENTS
Else
MsgBox("no address selected")
End If
Catch ex As Exception
MsgBox("Error occured:" & vbCrLf & ex.Message, MsgBoxStyle.Critical, "VBCITY.VBTAPI")
End Try
' by now we are done for the initialization and registration and the events should fire
' Note: you must dispose of tapi befor you destroy the class and i will leave this for now
End Sub
Private Sub oTAPI_Event(ByVal TapiEvent As TAPI3Lib.TAPI_EVENT, ByVal pEvent As Object) Handles oTAPI.Event
' making a thread to asynchronosly process the event
Dim thAsyncCall As System.Threading.Thread
RaiseEvent tapiEvent(TapiEvent, pEvent)
Select Case TapiEvent
Case TAPI_EVENT.TE_CALLNOTIFICATION 'Call Notification Arrived
' assigning our sub's delegate to the thread
thAsyncCall = New Threading.Thread(AddressOf CallNotificationEvent)
'passing the variable for the thread
CallNotificationObject = CType(pEvent, ITCallNotificationEvent)
' starting the thread
thAsyncCall.Start()
Case TAPI_EVENT.TE_CALLSTATE 'Call State Changes
' assigning our sub's delegate to the thread
thAsyncCall = New Threading.Thread(AddressOf CallStateEvent)
'passing the variable for the thread
CallStateObject = CType(pEvent, ITCallStateEvent)
' starting the thread
thAsyncCall.Start()
Case TAPI_EVENT.TE_CALLINFOCHANGE 'Call Info Changes
' assigning our sub's delegate to the thread
thAsyncCall = New Threading.Thread(AddressOf CallInfoEvent)
'passing the variable for the thread
CallInfoObject = CType(pEvent, ITCallInfoChangeEvent)
' starting the thread
thAsyncCall.Start()
End Select
End Sub
Private CallNotificationObject As ITCallNotificationEvent
Private Sub CallNotificationEvent()
' here we should check to see various notifications of new and ended calls
Select Case CallNotificationObject.Event
Case CALL_NOTIFICATION_EVENT.CNE_MONITOR
' the notification is for a monitored call
Case CALL_NOTIFICATION_EVENT.CNE_OWNER
' the notification is for an owned call
End Select
End Sub
Private CallStateObject As ITCallStateEvent
Private Sub CallStateEvent()
' here we should check to see call state and handle connects and disconnects
Select Case CallStateObject.State
Case CALL_STATE.CS_IDLE
Case CALL_STATE.CS_INPROGRESS
Case CALL_STATE.CS_OFFERING
' a call is offering so if you dont want it then pass it
' the code to pass the call is the following
'Dim CallControl As ITBasicCallControl = CallStateObject.Call
'CallControl.HandoffIndirect (CallStateObject.Call.CallInfoLong(CALLINFO_LONG.CIL_MEDIATYPESAVAILABLE)
Case CALL_STATE.CS_CONNECTED
' call is connected
Case CALL_STATE.CS_QUEUED
' call is beeing queued
Case CALL_STATE.CS_HOLD
' call is on hold
Case CALL_STATE.CS_DISCONNECTED
' call is disconnected
End Select
End Sub
Private CallInfoObject As ITCallInfoChangeEvent
Private Sub CallInfoEvent()
' here you can extract information from the call
'the code to extract the caller ID
' >>> put the following code in a try block and swallow the exception if it gives errors
Dim CallerID As String
CallerID = CallInfoObject.Call.CallInfoString(CALLINFO_STRING.CIS_CALLERIDNAME)
End Sub
Public Event tapiEvent(ByVal TapiEvent As TAPI3Lib.TAPI_EVENT, ByVal pEvent As Object)
End Class
End Namespace
|
|
|
|
|
Hi
I need your guidance to implement this using VB.NET. Appreciate your time, I will add your ID in my skype and send the details. Thanks a lot. OppsVen
|
|
|
|
|
I have this code and I am able to initiate or tigger a call in the built in dialer.exe of windows xp. To initiate a call Im using the IP address of my PC and H323 line as address. I just would like to modify this code (Im developing using web application in vb.net) to be able to retrieve the status of the call if disconnected, in progress, answered, etc and display it in a label. Im new in tapi coding and having a hard time understanding how it works. Really need help. thanks.
Imports TAPI3Lib
Partial Public Class _Default
Inherits System.Web.UI.Page
Private WithEvents oTAPI As TAPI3Lib.TAPI
Private ia As ITAddress() = New TAPI3Lib.ITAddress(9) {}
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim m_TAPI As New TAPIClass
m_TAPI.Initialize()
oTAPI = m_TAPI
m_TAPI = Nothing
Dim AddressCollection As ITCollection = oTAPI.Addresses()
DropDownList1.Items.Add("Select Option")
For i = 1 To AddressCollection.Count
Dim ln As ITAddress
ln = AddressCollection.Item(i)
ia(i) = ln
DropDownList1.Items.Add(ln.AddressName)
Next
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim ln As TAPI3Lib.ITAddress = Nothing
Dim bcc As ITBasicCallControl
ln = ia(DropDownList1.SelectedIndex)
Try
bcc = ln.CreateCall(TextBox1.Text, TapiConstants.LINEADDRESSTYPE_IPADDRESS, TapiConstants.TAPIMEDIATYPE_AUDIO)
bcc.Connect(False)
' not quite sure what to do with this placed comments
'oTAPI.EventFilter = (TAPI_EVENT.TE_CALLNOTIFICATION Or TAPI_EVENT.TE_CALLSTATE Or TAPI_EVENT.TE_CALLINFOCHANGE)
'Label1.Text = oTAPI.EventFilter
Catch ex As Exception
Label1.Text = ex.Message
End Try
End Sub
End Class
|
|
|
|
|
|
Hi Bishoy,
I am working mobile application, which will block call. I have code to block outgoing call but it is having one ring delay.
can we write code to block outgoing call without any notification and one ring delay.
Thanks in advance.
I am prashant working with Aurasoft Technologies solution Pvt. Ltd.
Prashant.
|
|
|
|
|
MediaModem is defined as a constant with a value of 16
this test asks: "if MediaModem =MediaModem "
surely that can't be right.
I'm new to this, but I can't see how it can be right. I'm suck can anybody shed light on it for me?
<br />
<br />
Thanks<br />
<br />
<br />
Ed
|
|
|
|
|
Hi Ed,
propably you've used something like this before its called Bitwise And operation and this statement is two parts to understand here
first "(MediaTypes And MediaModem)" and this will result 0 if MediTypes does not contain the value of MediaModem, otherwise it will return the value of MediaModem
and the second part is "If (MediaTypes And MediaModem) = MediaModem Then"
which will use the outcome of the first bitwise operation and compare it to the value of MediaModem and in this case it will succeed only if the result of the bitwise And operation yielded the Value of MediaModem.
and this is because MediaTypes variable contains multiple values combined together with Bitwise Oring, we must use Anding to check if one if the values exist or not.
"Imagination is more important than knowledge.."
{Albert Einstein}
|
|
|
|
|
|
I have downloaded the source code, created a form and created a new VBTAPI in the form, now how do i work with the events.
Thanks
|
|
|
|
|
Hi Everyone,
I was struggling to develope a TAPI Application to Make and Receive Calls through my Application.
I have been successfully able to Make Calls But Have not been Lucky Enough to Receive Incoming Calls Successfully.
Could you Please Provide me the Code to Monitor and Receive Incoming Calls?
Also, The Code Guru (Author) has mentioned "I will also include the full project as a download", Did anyone find on this Page or I am Blind enough to miss it?
Regards,
SAM.
|
|
|
|
|
Good afternoon!
I've done a program that reconized who calls. I get the incoming call number and search this into my database.
I've use the information of this article and works.
but I've a problem, when this programs is running X time, and after X time stops working. I don't know what happens, but is really strange. The aplication is like dead, but if you look the process information which is running into the pc (ctrl+alt+supr) you can see that my program is still running.
Someone have to solve this kind of problem???
I've thinking to restart automatically the program each hour, but ... I don't know if is is a good idea, because first I've to kill the program...
well, if some one has undertood me and could help I'll be very glad.
sorry for my bad english.
thank you
gemma
|
|
|
|
|
I can think of one scenario that could cause your problems,
try to make sure you dispose of your resources correctly (set unwanted references to null).
"Imagination is more important than knowledge.."
{Albert Einstein}
|
|
|
|
|
which name space do i need to include for TTERMINAL
|
|
|
|
|
how actually can I answer the incoming calls from a "Windows Application"
I wanted to notify me by an audio file , and give me the caller phone number ...
I think this could be done by putting the right code in "CallInfoEvent" subroutine , but none is executed when the phone rings.
by the way .... my modem is correctly connected to the phone cable , in case you wanted to tell me this ..
and one more thing ...
some events fire when I connect to the internet ,
or make a call by (C:\Windows\System32\dialer.exe)
any help please
|
|
|
|
|
hi,
can I save on my PC the faxes I receive on my phone line using TAPI ?
If yes, how can I catch the faxes ?
Thanks.
|
|
|
|
|
Hi,
I Have a question. How I can get sound when I call to a phone numer). When I dial the number, the phone device ring ok, but when I answer the a I have no sound. I' dont know wath Have I do to get sound. Please your help.
thanks in advance.
PD: Excuse my english, it's very poor
"To the shadow of the last tree will be a son of the bitch"
|
|
|
|
|
Did you know this? We tried to use TAPI version 3.x, but we changed to TAPI version 2.x because of a wrong event model in the COM-wrapper.
TAPI version 3.x never works for us in productive environment.
http://support.microsoft.com/default.aspx?scid=kb;en-us;841712[^]
Do you have any other experience with that?
Thanks.
|
|
|
|
|
Hi,
I have a telecom switch that have a callingcard servie, I dial a the DID from my phone and when I hear the ring I hung up, the switch call me immediately.
Can I do this from TAPI3, do I need to change the callerID, can I send a virtual callerID?
|
|
|
|
|
|
Hello All,
I need to know if there is a way to identify a call!
I want to open a window for each call, and close the correct window when the call is closed or terminated.
Normaly when there is only one call no problem, but I aspect a lot of calls during the same time.
Regards
Carsten
|
|
|
|
|
Hi,
first I'm a very early beginner with TAPI ad vb.net
In my testing code, I see incoming calls and can make a call.
But all events are triggerd very often. I can't see a system in this!
Is there a way to see, that this events are all based on the same call, if so?
My idea, I open a window for every call. But only for different calls.
regards
Carsten
modified on Thursday, June 5, 2008 1:03 PM
|
|
|
|
|
Hello Code Guru,
I'm currently working with your code example, but i encounter a strange error. I'm using visual studio 2005. When I first run my project the events fires as expected. I also got the disconnected event when I finish the phone call. But after that, nothing more happens. When the next call arrives NO event will be firing up and also no 3th party TAPI tool will get the next call. When I call the .shutdown method in the disconnected event handler, it's not getting much better, however 3th party TAPI tools will then get the next TAPI calls as usual. My program not ... But when I stop the project and run it again, it will work for the first call again. So I believe the call is not properly finished in some way, however, every code i found for .net has the same problems, but commercial 3th party tools don't. so there must be a way. Can you, or anyone other please point me in the right direction?. I've not much experience with TAPI at all, but this is a very strange behavior in my opinion. To be complete, I’m using the TAPI Drivers for Fritz BOX by AVM, a well known Manufacturer here in Germany.
Any help is greatly appreciated
Thanks
RoSch
|
|
|
|
|
I have the code verbatim as posted and I am getting a strange error when the following call is made:
CallInfoObject.Call.CallInfoString(CALLINFO_STRING.CIS_CALLERIDNAME)
Error HRESULT E_FAIL has been returned from a call to a COM component...
The Trace stack portion is below:
at Herbalife.VBCity.TAPI.VBTAPI.CallStateEvent() in C:\Documents and Settings\Ken\My Documents\Visual Studio Projects\Copy of Herbalife\tapi.vb:line 159
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at TAPI3Lib.ITCallInfo.get_CallInfoString(CALLINFO_STRING CallInfoString)
Any Ideas?
TIA
Ken Yannitell
|
|
|
|