Option Strict Off
Imports TAPI3Lib
Imports TAPI3Lib.TAPI_EVENT
Public Class GetCallID
Public gobjTapi1 As ITTAPI
Public gobjAddress1 As ITAddress
Public lngCallNot As Integer
Public gCall As ITCallInfo
Public WithEvents clTapi As TAPI
Public objCollAddresses As ITCollection
Public Const MyTapiEvents As Integer = TE_TAPIOBJECT Or TE_CALLNOTIFICATION Or TE_ADDRESS
Public Const LINECALLORIGIN_OUTBOUND = &H1
Public Const LINECALLORIGIN_INTERNAL = &H2
Public Const LINECALLORIGIN_EXTERNAL = &H4
Public Const LINECALLORIGIN_UNKNOWN = &H10
Public Const LINECALLORIGIN_UNAVAIL = &H20
Public Const LINECALLORIGIN_CONFERENCE = &H40
Public Const LINECALLORIGIN_INBOUND = &H80
Protected Overrides Sub OnStart(ByVal args() As String)
Try
gobjTapi1 = New TAPI
gobjTapi1.Initialize()
gobjTapi1.EventFilter = MyTapiEvents
clTapi = gobjTapi1
objCollAddresses = gobjTapi1.Addresses
Dim myaddress As ITAddress
For Each myaddress In objCollAddresses
If myaddress.AddressName = "Name of Telephony Provider" Then
lngCallNot = gobjTapi1.RegisterCallNotifications(myaddress, True, True, TAPI3Lib.TapiConstants.TAPIMEDIATYPE_AUDIO, 1)
End If
Next myaddress
Catch ex As Exception
"Error Message"
End Try
End Sub
Protected Overrides Sub OnStop()
Try
gobjTapi1.UnregisterNotifications(lngCallNot)
lngCallNot = Nothing
gCall = Nothing
gobjTapi1 = Nothing
gobjAddress1 = Nothing
objCollAddresses = Nothing
clTapi = Nothing
Catch ex As Exception
"Error Message"
End Try
End Sub
Private Sub TapiEvents(ByVal TapiEvent As TAPI3Lib.TAPI_EVENT, ByVal pEvent As Object) Handles clTapi.Event
Try
Select Case TapiEvent
Case TE_CALLNOTIFICATION
gCall = pEvent.Call
Select Case gCall.CallInfoLong(CALLINFO_LONG.CIL_ORIGIN)
Case LINECALLORIGIN_EXTERNAL
Dim CallerID as string = gCall.CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER)
.
.
.
End Select
End Select
Catch ex As Exception
"Error Message"
End Try
End Sub
Αυτό είναι ένα παράδειγμα του πώς να πάρεις το CallerID από μία τηλεφωνική συσκευή.
Στο internet υπάρχουν πολλά sites για να βρείς πληροφορίες για το TAPI,καλύτερα να αρχίσεις από το msdn
http://msdn.microsoft.com/en-us/library/ms734273(VS.85).aspx