Results 1 to 3 of 3

Thread: Why would this fail?

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    15

    Why would this fail?

    The TAPI has been initialized

    I get
    "Method 'RegisterCallNotifications' of object 'ITTAPI2' failed"

    HELP!

    Code:
    Sub RegisterEvents()
    
        'Set the EventFilter to accept all defined TAPI events.
        gobjTapi.EventFilter = TAPI3_CALL_EVENTS
        
        'Register the outgoing interface (the one that will actually
        'receive and process the events).
        Set gobjTapiWithEvents = gobjTapi
        Dim fOwner As Boolean, fMonitor As Boolean
        Dim lMediaTypes As Long, lCallbackInstance As Long
        
        'fOwner = True ensures that the application receives incoming calls
        'and their call state events.
        fOwner = True
        fMonitor = False
        lMediaTypes = TAPIMEDIATYPE_AUDIO
        lCallbackInstance = 1
        
        glRegistrationToken = gobjTapi.RegisterCallNotifications( _
            gobjAddress, _
            fMonitor, _
            fOwner, _
            lMediaTypes, _
            lCallbackInstance)
    
    End Sub


    Shahzad

  2. #2
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Why would this fail?

    show how you are declaring everything.
    Also please wrap you code in VBCODE tags rather than CODE tags

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    15

    Re: Why would this fail?

    Hey there! This is actually code you recommended to me before, I got most of it from microsoft, made some slight adjustments, but it's not flowing together.

    I have to leave work now, but I'll catch you at home...

    Here's the code


    VB Code:
    1. Public Sub Modem_stuff()
    2.  
    3.     Dim myTapiClass As New clsTAPI
    4.    
    5.     myTapiClass.InitializeTAPI
    6.     myTapiClass.SelectAnAddress
    7.     myTapiClass.RegisterEvents
    8.     myTapiClass.ReceiveACall
    9.     myTapiClass.SelectATerminal
    10.    
    11.     'MsgBox ("Modem Stuff Done")
    12. End Sub
    13.  
    14.  
    15. <here's the class clsTAPI that I declared as myTapiClass>
    16.  
    17. 'Usually declared globally
    18. Dim WithEvents gobjTapiWithEvents As TAPI
    19. Dim glRegistrationToken As Long
    20.  
    21. 'Usually declared globally
    22. Dim gobjTapi As TAPI
    23.  
    24. Dim gobjAddress As ITAddress2
    25.    
    26.  
    27. 'Usually performed at the same time
    28. 'as TAPI initialization
    29. Const TAPI3_CALL_EVENTS = _
    30.     TE_CALLMEDIA Or _
    31.     TE_CALLNOTIFICATION Or _
    32.     TE_CALLSTATE
    33.  
    34.  
    35. Sub InitializeTAPI()
    36.     ' Set error handling routine
    37.     ' On Error GoTo MyErrorRoutine
    38.      
    39.     'Usually performed during form load
    40.     'Create the tapi object.
    41.     Set gobjTapi = New TAPI
    42.    
    43.     'Call Initialize before calling any other TAPI function.
    44.     Call gobjTapi.Initialize
    45. End Sub
    46.  
    47. Sub SelectAnAddress()
    48.    'On Error GoTo MyErrorRoutine
    49.    
    50.     'pick up the collection of Address objects
    51.     Dim objCollAddresses As ITCollection
    52.     Set objCollAddresses = gobjTapi.Addresses
    53.    
    54.     'find address that supports the desired type, nSelectedType
    55.     bFound = False
    56.     For indexAddr = 1 To objCollAddresses.Count
    57.         Set objCrtAddress = objCollAddresses.Item(indexAddr)
    58.         Set objMediaSupport = objCrtAddress
    59.         Set objAddressCapabilities = objCrtAddress
    60.    
    61.         If objMediaSupport.QueryMediaType(TAPIMEDIATYPE_AUDIO) Then
    62.             bFound = True
    63.         End If
    64.        
    65.         Set objAddressCapabilities = Nothing
    66.         Set objMediaSupport = Nothing
    67.         Set objCrtAddress = Nothing
    68.        
    69.         If bFound = True Then Exit For
    70.     Next indexAddr
    71.    
    72.     Set gobjAddress = objCollAddresses.Item(indexAddr)
    73. End Sub
    74.  
    75. Sub RegisterEvents()
    76.  
    77.     'Set the EventFilter to accept all defined TAPI events.
    78.     gobjTapi.EventFilter = TAPI3_CALL_EVENTS
    79.    
    80.     'Register the outgoing interface (the one that will actually
    81.     'receive and process the events).
    82.     Set gobjTapiWithEvents = gobjTapi
    83.     Dim fOwner As Boolean, fMonitor As Boolean
    84.     Dim lMediaTypes As Long, lCallbackInstance As Long
    85.    
    86.     'fOwner = True ensures that the application receives incoming calls
    87.     'and their call state events.
    88.     fOwner = True
    89.     fMonitor = False
    90.     lMediaTypes = TAPIMEDIATYPE_AUDIO
    91.     lCallbackInstance = 1
    92.    
    93.     glRegistrationToken = gobjTapi.RegisterCallNotifications( _
    94.         gobjAddress, _
    95.         fMonitor, _
    96.         fOwner, _
    97.         lMediaTypes, _
    98.         lCallbackInstance)
    99.  
    100. End Sub
    101.  
    102.  
    103. Sub SelectATerminal()
    104.     ' Set error handling routine
    105.     ' On Error GoTo MyErrorRoutine
    106.    
    107.     'query for ITBasicCallControl, the call control interface
    108.     Dim objCallControl As ITBasicCallControl
    109.     Set objCallControl = gobjReceivedCallInfo
    110.    
    111.     'query ITTerminalSupport from Address object
    112.     Dim objTerminalSupport As ITTerminalSupport
    113.     Set objTerminalSupport = gobjAddress
    114.    
    115.     Dim objTerminal As ITTerminal
    116.     Set objTerminal = objTerminalSupport.GetDefaultStaticTerminal( _
    117.         lMediaType, Dir)
    118.    
    119.     'release not needed objects
    120.     Set objTerminalSupport = Nothing
    121.    
    122.     'Select the terminal before answering
    123.     'we'll need the ITStreamControl interface for doing this.
    124.    
    125.     Dim objStreamControl As ITStreamControl
    126.     Set objStreamControl = objCallControl
    127.    
    128.     If Not (objStreamControl Is Nothing) Then
    129.         Dim objITCollStreams As ITCollection
    130.        
    131.         Set objITCollStreams = objStreamControl.Streams
    132.        
    133.         Dim nIndex As Long, objCrtStream As ITStream
    134.        
    135.         For nIndex = 1 To objITCollStreams.Count
    136.             Set objCrtStream = objITCollStreams.Item(nIndex)
    137.             If objCrtStream.MediaType = lMediaType Then
    138.                 If objCrtStream.Direction = Dir Then
    139.                     Call objCrtStream.SelectTerminal(objTerminal)
    140.                 End If
    141.             End If
    142.             Set objCrtStream = Nothing
    143.         Next nIndex
    144.        
    145.         Set objITCollStreams = Nothing
    146.         Set objStreamControl = Nothing
    147.     End If
    148. End Sub
    149.  
    150. Sub ReceiveACall()
    151.     If TapiEvent = TE_CALLNOTIFICATION Then
    152.         ' Get the ITCallNotification interface.
    153.         Dim objCallNotificationEvent As ITCallNotificationEvent
    154.         Set objCallNotificationEvent = pEvent
    155.    
    156.        'query ITCallInfo interface for the new call, and store it
    157.         Dim gobjReceivedCallInfo As ITCallInfo
    158.         Set gobjReceivedCallInfo = objCallNotificationEvent.Call
    159.    
    160.         ' Get the ITBasicCallControl interface.
    161.         Dim objCallControl As ITBasicCallControl
    162.         Set objCallControl = gobjReceivedCallInfo
    163.    
    164.         ' Create the required terminals for this call.
    165.         ' See the Select a Terminal code example.
    166.        
    167.         'Answer
    168.         objCallControl.answer
    169.     End If
    170. End Sub

    Thanks a ton! This has sure been a brain wrecker for me... Just having a hard time figuring out how to use these APIs.


    Shahzad

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width