Problem: It only works on the first incomming call !!
I need help to troubleshoot it.
Thanks,
Eduardo
Instructions:
* Create a new Windows Application Project in Visual Studio .NET
* Add a reference to TAPI3Lib (Right Click on Project >> Select Add
References >> Select the COM tab >> Select "Microsoft TAPI 3.0 Type Library"
>> Click Select >> Click OK)
* Delete all the code from your Form1.vb (ALL CODE, including the class)
*Copy the code below and paste it to Form1.vb
*Run the project, select your modem from the combobox, click on "Start
Monitoring" and caller id information will appear on the textbox upon your
first call.
'*****Copy the code bellow this line
Option Strict Off
Imports TAPI3Lib
Imports TAPI3Lib.TAPI_EVENT
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.Button1 = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'ComboBox1
'
Me.ComboBox1.Location = New System.Drawing.Point(8, 16)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(392, 21)
Me.ComboBox1.TabIndex = 0
Me.ComboBox1.Text = "ComboBox1"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(416, 8)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(120, 40)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Start Monitoring"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(8, 56)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.TextBox1.Size = New System.Drawing.Size(528, 288)
Me.TextBox1.TabIndex = 2
Me.TextBox1.Text = "TextBox1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(544, 350)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.ComboBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Public gobjTapi1 As ITTAPI
Public gobjAddress1 As ITAddress
Public lngCallNot As Integer
Public gCall As ITCallInfo
Public gHub As ITCallHub
Public WithEvents clTapi As TAPI
Public objCollAddresses As ITCollection
Public Const MyTapiEvents As Integer = TE_TAPIOBJECT Or TE_ADDRESS Or _
TE_CALLNOTIFICATION Or TE_CALLSTATE Or TE_CALLMEDIA Or TE_CALLHUB Or _
TE_CALLINFOCHANGE Or TE_PRIVATE Or TE_REQUEST Or TE_AGENT Or TE_AGENTSESSION
Or _
TE_QOSEVENT Or TE_AGENTHANDLER Or TE_ACDGROUP Or TE_QUEUE Or TE_DIGITEVENT
Or _
TE_GENERATEEVENT Or TE_ASRTERMINAL Or TE_TTSTERMINAL Or TE_FILETERMINAL Or _
TE_TONETERMINAL Or TE_PHONEEVENT Or TE_TONEEVENT Or TE_GATHERDIGITS
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles Button1.Click
Dim TapiConstants As Object
Dim iTest As Short
If ComboBox1.SelectedIndex > -1 Then
gobjAddress1 = objCollAddresses.Item(ComboBox1.SelectedIndex + 1)
Console.WriteLine("Monitoring: " & gobjAddress1.AddressName)
lngCallNot = gobjTapi1.RegisterCallNotifications(gobjAddress1, True, True,
TAPI3Lib.TapiConstants.TAPIMEDIATYPE_DATAMODEM, 1)
End If
Console.WriteLine("Address Set to: " & gobjAddress1.AddressName)
End Sub
Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs
As System.EventArgs) Handles MyBase.Load
gobjTapi1 = New TAPI
gobjTapi1.Initialize()
gobjTapi1.EventFilter = MyTapiEvents
clTapi = gobjTapi1
objCollAddresses = gobjTapi1.Addresses
Dim myaddress As ITAddress
For Each myaddress In objCollAddresses
ComboBox1.Items.Add((myaddress.AddressName))
Next myaddress
End Sub
Private Sub Form1_Closed(ByVal eventSender As System.Object, ByVal eventArgs
As System.EventArgs) Handles MyBase.Closed
gobjTapi1.UnregisterNotifications(lngCallNot)
gCall = Nothing
gobjTapi1 = Nothing
gobjAddress1 = Nothing
objCollAddresses = Nothing
clTapi = Nothing
End Sub
Private Sub TapiEvents(ByVal TapiEvent As TAPI3Lib.TAPI_EVENT, ByVal pEvent
As Object) Handles clTapi.Event
Select Case TapiEvent
Case TE_ADDRESS
Console.WriteLine(Now & " Address_Event: " & pEvent.Event)
Case TE_CALLNOTIFICATION
Console.WriteLine(Now & " CallNotification_Event: " & pEvent.Event)
Case TE_CALLSTATE
Console.WriteLine(Now & " CallState_Event - State: " & pEvent.State & "
Cause: " & pEvent.Cause)
Case TE_CALLHUB
Select Case pEvent.Event
Case 0
gCall = pEvent.Call
Case 2
gHub = pEvent.CallHub
Case 3
End Select
Console.WriteLine(Now & " CallHub_Event: " & pEvent.Event & " Calls: " &
pEvent.CallHub.NumCalls & " State: " & pEvent.CallHub.State)
Case TE_CALLINFOCHANGE
If pEvent.Cause = 14 Then
Console.WriteLine(Now & " " & "CALLINFO_STRING.CIS_CALLERIDNUMBER: " &
gCall.CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER))
Console.WriteLine(Now & " " & "CALLINFO_STRING.CIS_CALLERIDNAME: " &
gCall.CallInfoString(CALLINFO_STRING.CIS_CALLERIDNAME))
TextBox1.Text = TextBox1.Text & "CALLINFO_STRING.CIS_CALLERIDNUMBER: " &
gCall.CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER) & vbCrLf
TextBox1.Text = TextBox1.Text & "CALLINFO_STRING.CIS_CALLERIDNAME: " &
gCall.CallInfoString(CALLINFO_STRING.CIS_CALLERIDNAME) & vbCrLf
End If
If pEvent.Cause <> 12 Then
Console.WriteLine(Now & " CallInfoChange_Event - Cause: " & pEvent.Cause)
End If
Case Else
Console.WriteLine("Other Event not handled")
End Select
End Sub
End Class
'********* END OF CODE ******** DO NOT COPY THIS LINE*******
Eduardo,
please attach you VB project with all necessary files as ZIP to a posting.
This is much more convenient for some one who wants to reproduce with your
code.
Regarding TAPI and .NET see KB article "841712 - Telephony Application
Programming Interface (TAPI) functionality is not supported from managed
code".
What device / TSP are you using?
If it is a modem with UniModem.TSP:
you need to release every(!) call related resource.
UniModem.TSP supports only one call, so if you still have a reference to the
old
call you won't be notified about a new one.
Try it with TAPI Browser TB3x before starting to code anything yourself.
Take a look at the TAPI samples (Incoming, Outgoing) from P-SDK.
See my TAPI and TSPI FAQ:
Q: Is there any sample code available ?
http://www.i-b-a-m.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm#_Q:_Is_there
Q: Where can I download TAPI Browser ?
http://www.i-b-a-m.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm#_Q:_Where_can
Q: Is there a user guide available for TAPI Browser TB3x ?
http://www.i-b-a-m.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm#_Q:_Is_there_2
Q: Are there any KB articles on TAPI available ?
http://www.i-b-a-m.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm#_Q:_Are_there_7
Q: Are there any .NET wrappers for TAPI2 available ?
http://www.i-b-a-m.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm#_Q:_Are_there_4
--
Best Regards
Andreas Marschall
Microsoft MVP for TAPI / Windows SDK
TAPI / TSP Developer and Tester
http://www.I-B-A-M.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm
* Please post all messages and replies to the newsgroup so all may
* benefit from the discussion. Private mail is usually not replied to.
* This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Andreas,
You have an awesome site for TAPI and it was sure a lot if informative
reading.
Based on your help, the program is working now but not as I would like.
Here is what I did:
TB3x -
Is working fine and I attached a logfile for your review if possible.
I used the IUnknown.Release on each references to the call until the number
of calls for the ITAddress was 0.
After releasing the call, all the events were generated again upon a new
incoming call.
Is there a better way on TB3x to release the call?
My VB.NET project -
ITCallInfo inherits IUnknown but I don't know how to call the release method
from code. The only way I found to release the call was by using the
ITTapi.UnregisterNotifications.
I read that the ITBasicCallControl..Disconnect releases the call, but I
couldn't generate this object. If this is correct, how can I have a
reference to the ITBasicCallControl?
So, back to the code, I changed the following under the TapiEvents >> Case
Te_CallHUB >> Case CallHubEvent = 3
Private Sub TapiEvents.........
.........
Case TE_CALLHUB
Select Case pEvent.Event
Case 0
gCall = pEvent.Call
Case 2
gHub = pEvent.CallHub
Case 3 'NEW LINES BELLOW
gobjTapi1.UnregisterNotifications(lngCallNot)
lngCallNot = gobjTapi1.RegisterCallNotifications(gobjAddress1,
True, True, TAPI3Lib.TapiConstants.TAPIMEDIATYPE_DATAMODEM, 1)
End Select
........................
I attached a copy of my project (prjCallerID.zip) and it is working but I
don't like it for the following reasons:
* It sounds wrong to release the call by using the
UnregisterNotification and then doing again RegisterCallNotification. There
must be a better way to release the call.
* The call is released only after the CallHub goes Idle. The callHub
goes idle only after a certain amount of time after the last ring and only
then the program will be ready to receive another call. If I have a first
caller that hangsup the phone before I answer the call and a second caller
starts ringing before the hub goes idle my code will not detect the new call
and will think it is still the first caller ringing. Bellow are a few
timelines to illustrate the problem.
Caller1
Ring Ring Ring HangUp
|--------------------|--------------------|----------|
Caller2
Ring Ring Ring
--------------------------------------------------------|--------------------|--------------------|
Current Tapi
Ring CIDInfo1 Ring Ring Ring
Ring Ring
|---------|-----------|--------------------|--------------|--------------------|--------------------|
Desired Tapi
Ring CIDInfo1 Ring Ring Ring
CIDInfo2 Ring Ring
|---------|-----------|--------------------|--------------|--------|------------|--------------------|
One idea is to use the UnregisterNotification/RegisterCallNotification after
each ring, but again it doesn't sound right.
I would much appreciate if you could help me solve this problem.
Thanks a lot.
Eduardo
PS.
Cuba.dll sounds great but I would prefer to have my own code if possible.
The C# Wrapper for Tapi 2 by Helen Warn is not CLR and I would have to
convert it so I could use it with VB.
KB article 841712 - I don't know how to create an unmanaged DLL that calls
TAPI 3.x functionality. Maybe for the few TAPI functions I need it works.
TB3x Log:
ITTAPI.CreateInstance ITTAPI_1
returned hr = 0x00000000
ITTAPI_1.Initialize returned hr = 0x00000000
ITTAPI_1.put_EventFilter
long plFilterMask : 127 (0x0000007f)
returned hr = 0x00000000
ITTAPI_1.EnumerateAddresses returned hr = 0x00000000
IEnumAddress_1
IEnumAddress_1.Next ITAddress2_1
returned hr = 0x00000000
ITAddress2_1.get_AddressName returned hr = 0x00000000
BSTR* ppName = Intel(R) 537EP V9x DF PCI Modem
ITTAPI_1.AdviseEventNotification returned hr = 0x00000000
cookie 990
ITTAPI_1.RegisterCallNotifications
ITAddress* pAddress : ITAddress2_1
VARIANT_BOOL fMonitor : 1
VARIANT_BOOL fOwner : 1
long lMediaTypes : 16 (0x00000010)
long lCallbackInstance : 990 (0x000003de)
returned hr = 0x00000000
long* plRegister = 956 (0x000003bc)
ITCallHubEvent_1
TAPI_EVENT const int TE_CALLHUB
ITCallHubEvent_2
TAPI_EVENT const int TE_CALLHUB
ITCallNotificationEvent_1
TAPI_EVENT const int TE_CALLNOTIFICATION
ITCallStateEvent_1
TAPI_EVENT const int TE_CALLSTATE
ITAddressEvent_1
TAPI_EVENT const int TE_ADDRESS
ITCallInfoChangeEvent_1
TAPI_EVENT const int TE_CALLINFOCHANGE
ITCallInfoChangeEvent_2
TAPI_EVENT const int TE_CALLINFOCHANGE
ITAddressEvent_2
TAPI_EVENT const int TE_ADDRESS
ITCallInfoChangeEvent_2.get_Call returned hr = 0x00000000
ITCallInfo** ppCall = ITCallInfo2_1
ITCallHubEvent_3
TAPI_EVENT const int TE_CALLHUB
ITCallStateEvent_2
TAPI_EVENT const int TE_CALLSTATE
ITCallInfo2_1.get_CallInfoString
CALLINFO_STRING CallInfoString : 0
returned hr = 0x00000000
BSTR* ppCallInfoString = WIRELESS CALLER
ITCallStateEvent_2.Release
ITCallHubEvent_3.Release
ITCallInfo2_1.Release
ITAddressEvent_2.Release
ITCallInfoChangeEvent_2.Release
ITCallInfoChangeEvent_1.Release
ITAddressEvent_1.Release
ITCallStateEvent_1.Release
ITCallNotificationEvent_1.Release
ITCallHubEvent_2.Release
ITCallHubEvent_1.Release
ITCallHubEvent_4
TAPI_EVENT const int TE_CALLHUB
ITCallHubEvent_5
TAPI_EVENT const int TE_CALLHUB
ITCallNotificationEvent_2
TAPI_EVENT const int TE_CALLNOTIFICATION
ITCallStateEvent_3
TAPI_EVENT const int TE_CALLSTATE
ITAddressEvent_3
TAPI_EVENT const int TE_ADDRESS
ITCallInfoChangeEvent_3
TAPI_EVENT const int TE_CALLINFOCHANGE
ITCallInfoChangeEvent_4
TAPI_EVENT const int TE_CALLINFOCHANGE
ITCallHubEvent_6
TAPI_EVENT const int TE_CALLHUB
ITCallStateEvent_4
TAPI_EVENT const int TE_CALLSTATE
ITCallStateEvent_4.get_Call returned hr = 0x00000000
ITCallInfo** ppCallInfo = ITCallInfo2_2
ITCallInfo2_2.get_CallInfoString
CALLINFO_STRING CallInfoString : 0
returned hr = 0x00000000
BSTR* ppCallInfoString = WIRELESS CALLER
IEnumAddress_1.Release
ITAddress2_1.Release
ITCallHubEvent_4.Release
ITCallHubEvent_5.Release
ITCallNotificationEvent_2.Release
ITCallStateEvent_3.Release
ITAddressEvent_3.Release
ITCallInfoChangeEvent_3.Release
ITCallInfoChangeEvent_4.Release
ITCallHubEvent_6.Release
ITCallStateEvent_4.Release
ITCallInfo2_2.Release
ITTAPI_1.Shutdown returned hr = 0x00000000
ITTAPI_1.Release
"Andreas Marschall [MVP TAPI]" <Andreas....@I-B-A-M.de> wrote in
message news:uyRkZRL7...@TK2MSFTNGP10.phx.gbl...
see my TAPI VB.NET code: http://www.vbcity.com/forums/topic.asp?tid=88933
see other VB.NET code : http://www.vbcity.com/forums/topic.asp?tid=43957
"Xpto" <xpto...@comcast.net> wrote in message
news:AcGdnXupCJh...@comcast.com...
"Bishoy Ghaly" <bis...@dev2dev.org> wrote in message
news:%23N8o671...@TK2MSFTNGP12.phx.gbl...
"Xpto" <xpto...@comcast.net> wrote in message
news:DJqdnb9BJKK...@comcast.com...