Link to home
Start Free TrialLog in
Avatar of Daerimin
Daerimin

asked on

TAPI woes

Greetings all!

I have had a great deal of trouble finding information about TAPI 3.1, as I'm sure a lot of people have.  It's the single most poorly documented & cryptic item I have ever encountered as a software developer.  I have broken into the technology a bit, and have successfully coded a small app that will answer the phone, show caller ID info, etc.  However, it only works once.  I have to shut down VB6 and start over.  I can't seem to get it to release the resources properly.  Here's my code:

Public objCallNotificationEvent As ITCallNotificationEvent
Public gobjReceivedCallInfo As ITCallInfo
Public objCallControl As ITBasicCallControl
Public gobjTAPIRegToken As Long
Public gobjAddress As ITAddress
Public objCollAddresses As ITCollection
Public gobjTAPI As New TAPI
Public WithEvents gobjTAPIWithEvents As TAPI

Const TAPI3_CALL_EVENTS = _
  TE_CALLMEDIA Or _
  TE_CALLNOTIFICATION Or _
  TE_CALLSTATE Or _
  TE_DIGITEVENT
 
Private Sub Form_Load()
  gobjTAPI.Initialize
  Set objCollAddresses = gobjTAPI.Addresses
  For j = 1 To objCollAddresses.Count
    Set gobjAddress = objCollAddresses.Item(j)
    frm_Main.cmb_Address.AddItem gobjAddress.AddressName, cmb_Address.ListCount
    If gobjAddress.AddressName = GetSetting("IVR", "Config", "Address") Then
      frm_Main.cmb_Address.ListIndex = j - 1
    End If
  Next j
  gobjTAPI.EventFilter = TAPI3_CALL_EVENTS
  Set gobjTAPIWithEvents = gobjTAPI
  gobjTAPIRegToken = gobjTAPI.RegisterCallNotifications(gobjAddress, False, True, TAPIMEDIATYPE_AUDIO, 1)
End Sub

Private Sub Form_Unload(Cancel As Integer)
  objCallControl.Disconnect DC_NORMAL
  gobjTAPI.UnregisterNotifications gobjTAPIRegToken
  gobjTAPI.Shutdown
End Sub

Private Sub gobjTAPIWithEvents_Event(ByVal TapiEvent As TAPI3Lib.TAPI_EVENT, ByVal pEvent As Object)
  If TapiEvent = TE_CALLNOTIFICATION Then
    Set objCallNotificationEvent = pEvent
    Set gobjReceivedCallInfo = objCallNotificationEvent.Call
    Set objCallControl = gobjReceivedCallInfo
    tim_CID.Enabled = True
    objCallControl.Answer
  End If
  If TapiEvent = TE_CALLSTATE Then
    Set gobjReceivedCallInfo = objCallNotificationEvent.Call
    Set objCallControl = gobjReceivedCallInfo
    Debug.Print "CALL STATE: " & gobjReceivedCallInfo.CallState
    If gobjReceivedCallInfo.CallState = 3 Then
      On Error Resume Next
      objCallControl.Disconnect DC_NORMAL
      On Error GoTo 0
      Set gobjReceivedCallInfo = Nothing
      Set objCallControl = Nothing
      Set objCallNotificationEvent = Nothing
    End If
  End If
End Sub

Private Sub tim_CID_Timer()
  If lbl_CID.Caption > "" Then
    tim_CID.Enabled = False
    Exit Sub
  End If
  On Error Resume Next
  a$ = gobjReceivedCallInfo.CallInfoString(CIS_CALLERIDNAME)
  b$ = gobjReceivedCallInfo.CallInfoString(CIS_CALLERIDNUMBER)
  lbl_CID.Caption = a$ + vbCrLf + b$
  On Error GoTo 0
End Sub



Could somebody advise me on how to reset my universe so the next call will function properly?  FYI, the modem I am using shows up as the following on XP Pro:

Conexant SmartSCM External PnP, V.90, K56Flex,Voice,Speakerphone

Thanks in advance!!!
~Joel
Avatar of Maritimer
Maritimer

Just tagging along to learn something new......
if you are into investing some money i would recommend the vbvoice (http://www.pronexus.com/tools/vbvoice.html) it is a complete toolkit for TAPI with alot of features.
Daerimin:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
Avatar of DanRollins
Daerimin, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Refund points and save as a 0-pt PAQ.

DanRollins -- EE database cleanup volunteer
ASKER CERTIFIED SOLUTION
Avatar of YensidMod
YensidMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial