Im trying to interface with tapi3.dll from the windows system32 directory by importing it as a com automation class, I need it to make and receive calls on an Avaya phone system.
I can make calls successfully using the below procedure TapiCall, but when I try to register an event to receive calls, using the below procedure TapiRegisterEvent, the event is never called.
I based the code on a C# example that works just fine, but in Dataflex the event is never called.
I have very little experience working with com automation so I might be missing something, so if anyone can see if there is something missing in the code (besides the cleanup stuff like destroy object and release com object), or even better have worked with tapi3.dll, then please help, Im all out of ideas myself.
Code:
Object oTAPI is a cComTAPI
Set peAutoCreate to acAutoCreate
Procedure OnComEvent OLETAPI_EVENT llTapiEvent Variant llpEvent
Forward Send OnComEvent llTapiEvent llpEvent
End_Procedure
End_Object
Procedure TapiRegisterEvent
Integer iReg iEvents
Variant vAddress vAddressCollection
Handle hAddress hCollection
Get Create U_cComITAddress to hAddress
Get Create U_cComITCollection to hCollection
// Event Filter
Move (OLETE_CALLNOTIFICATION ior OLETE_DIGITEVENT ior OLETE_PHONEEVENT ior OLETE_CALLSTATE ior OLETE_GENERATEEVENT ior OLETE_GATHERDIGITS ior OLETE_REQUEST) to iEvents
// Initialize TAPI.
Send ComInitialize of oTAPI
// Set Event Filter.
Set ComEventFilter of oTAPI to iEvents
// Active Lines and a line is chosen
Get ComAddresses of oTAPI to vAddressCollection
Set pvComObject of hCollection to vAddressCollection
Get ComItem of hCollection 6 to vAddress
// Reg: Notifications.
Get ComRegisterCallNotifications of oTAPI vAddress True True 8 2 to iReg
End_Procedure
Procedure TapiCall
Variant vAddress vAddresses vCallControl
Handle hAddress hCollection hCallControl
Get Create U_cComITCollection to hCollection
Get Create U_cComITAddress to hAddress
Get Create U_cComITBasicCallControl to hCallControl
// Initialize TAPI.
Send ComInitialize of oTAPI
// Active Lines.
Get ComAddresses of oTAPI to vAddresses
Set pvComObject of hCollection to vAddresses
Get ComItem of hCollection 6 to vAddress
Set pvComObject of hAddress to vAddress
Get ComCreateCall of hAddress "473" 0 8 to vCallControl
// Set pvComobject and make a call.
Set pvComObject of hCallControl to vCallControl
Send ComConnect of hCallControl True
End_Procedure