Caller ID via TAPI (tapi32.dll) from phone phone PBX

bignose2

Registered User.
Local time
Today, 17:05
Joined
May 2, 2010
Messages
240
Hi,

use to use an OCX that would connect to Windows/phone & modems settings & then to the TAPI setup from my NEC phone system
Basically the ocx could list all those devices & connect.

I just use to get caller ID & log all those who phone in.

Seems to have just stopped working, I think MS is depreciating ocx perhaps? mine was from 2003 I think.

Anyway MS seems to have their own, via tapi32.dll

very little VBA anywhere, few snippets but nothing I can get started with.
I first of all need to list all the devices & then select, I cannot seem to get anything on this.

Fair bit on the actual references to many functions but not how you implement.


Just some I found from elswhere but cannot get started until I would out how to point to my "NEC1100" TAPI devide

Code:
Public Const ID_CANCEL = 2
Public Const MB_OKCANCEL = 1
Public Const MB_ICONSTOP = 16, MB_ICONINFORMATION = 64

Declare Function tapiRequestMakeCall Lib "tapi32.dll" _
(ByVal stNumber As String, ByVal stDummy1 As String, _
ByVal stDummy2 As String, ByVal stDummy3 As String) As Long

Function DialNumber(PhoneNumber, Optional vName As Variant)
Dim Msg As String, MsgBoxType As Integer, MsgBoxTitle As String
Dim RetVal As Long
' Ask the user to pick up the phone.
Msg = "Please pickup the phone and click OK to dial " _
& Chr(13) & Chr(13) & PhoneNumber & " " & vName
RetVal = tapiRequestMakeCall(PhoneNumber, "", vName, "")
If RetVal < 0 Then
Msg = "Unable to dial number " & PhoneNumber
GoTo Err_DialNumber
End If
Exit Function
Err_DialNumber: 'This is not an On Error routine.
Msg = Msg & Chr(13) & Chr(13) & _
"Make sure no other devices are using the Com port"
End Function

'You can find the caller ID string at LINECALLINFO.dwCallerIDOffset/Size when
'LINECALLINFO.dwCallerIDFlags contains LINECALLPARTYID_ADDRESS.
'You can retrieve this structure by lineGetCallInfo() for a new call and on any
'changes notified via LINE_CALLINFO(LINECALLINFOSTATE_CALLERID) message.
'Test it with TB20.
 
I asked Chatty, might help, might be delusional!

The issue described involves accessing and interacting with TAPI (Telephony Application Programming Interface) using VBA and the tapi32.dll library to manage a phone system and retrieve Caller ID. It appears that the previous OCX solution has become obsolete, and you're looking to use tapi32.dll directly.

Here’s how you might approach this:

1. Accessing TAPI Devices

Before you can retrieve Caller ID or make calls, you must enumerate the available TAPI devices. Unfortunately, VBA has limited direct support for advanced TAPI functions, so some Windows API calls are needed. Below is a basic outline:

Code Example to Enumerate Devices

Declare Function lineInitialize Lib "tapi32.dll" (ByRef hLineApp As Long, _
ByVal hInstance As Long, ByVal lpfnCallback As Long, _
ByRef lpdwNumDevs As Long) As Long

Declare Function lineGetDevCaps Lib "tapi32.dll" (ByVal hLineApp As Long, _
ByVal dwDeviceID As Long, ByVal dwAPIVersion As Long, _
ByVal dwExtVersion As Long, ByRef lpLineDevCaps As Byte) As Long

Sub ListTAPIDevices()
Dim hLineApp As Long
Dim numDevs As Long
Dim i As Long
Dim result As Long

' Initialize TAPI
result = lineInitialize(hLineApp, 0, 0, numDevs)
If result <> 0 Then
MsgBox "Failed to initialize TAPI. Error: " & result
Exit Sub
End If

' Enumerate devices
For i = 0 To numDevs - 1
' Retrieve device capabilities (simplified)
MsgBox "Device ID: " & i
' Implement additional calls to lineGetDevCaps for detailed info
Next i
End Sub

This code initializes TAPI and attempts to list available devices. You'll need to add more error handling and specific calls to retrieve details about each device using lineGetDevCaps.

2. Retrieving Caller ID

Caller ID is part of the LINECALLINFO structure, accessed via lineGetCallInfo. This requires more advanced handling, including managing callbacks to capture events (e.g., incoming calls).

For VBA, you would need to:

1. Set up lineOpen to establish a connection to a device.

2. Handle events via lineGetMessage to detect incoming calls.

3. Use lineGetCallInfo to extract Caller ID.

However, this may be too complex for VBA alone, so a VB.NET or COM-based intermediary might simplify this.

3. Switching to Modern Alternatives

If working with tapi32.dll directly becomes cumbersome:

Consider using a third-party TAPI library or SDK (e.g., ExceleTel TAPI Link).

Switch to VB.NET or C# for easier API interaction, with the ability to expose simplified functionality to Access.

4. Deprecation Note

OCX components have largely been deprecated due to security and compatibility concerns. It’s better to use API-level integration or modern libraries. Ensure that your TAPI service (from the NEC phone system) is still functional and properly configured on your system.
 

Users who are viewing this thread

Back
Top Bottom