可以做到,使用TAPI编程即可.
这是一个VB的例子:
Imports TAPI3Lib
Public Class cTAPI
Dim gobjTapi As TAPI
Dim WithEvents gobjTapiWithEvents As TAPI
Dim glRegistrationToken As Long
Dim gobjReceivedCallInfo As ITCallInfo
Dim gbSupportedCall As Boolean
Const TAPI3_CALL_EVENTS = TAPI_EVENT.TE_CALLMEDIA Or
TAPI_EVENT.TE_CALLNOTIFICATION Or TAPI_EVENT.TE_CALLSTATE
Public Sub New()
gobjTapi = New TAPI()
Call gobjTapi.Initialize()
Dim gobjAddress As ITAddress
Dim objCollAddresses As ITCollection
Dim bfound As Boolean
Dim indexAddr As Integer
Dim objCrtAddress As ITAddress
Dim objMediaSupport As ITMediaSupport
Dim objAddressCapabilities As ITAddressCapabilities
objCollAddresses = gobjTapi.Addresses
bfound = False
For indexAddr = 1 To objCollAddresses.Count
objCrtAddress = objCollAddresses.Item(indexAddr)
objMediaSupport = objCrtAddress
objAddressCapabilities = objCrtAddress
If objMediaSupport.QueryMediaType(TapiConstants.TAPIMEDIATYPE_AUDIO)
Then
bfound = True
End If
objAddressCapabilities = Nothing
objMediaSupport = Nothing
objCrtAddress = Nothing
If bfound = True Then Exit For
Next indexAddr
'gobjAddress = objCollAddresses.Item(indexAddr)
'musste ich rausnehmen, da sonst gobjTapi.RegisterCallNotifications
(ca Line
57) abraucht - bei mir wird bei
'indexAddr = 1 = 7 = 8 bfound = true, aber nur bei indexAddr = 8 wird
der
Handler registriert
gobjAddress = objCollAddresses.Item(8)
gobjTapi.EventFilter = TAPI3_CALL_EVENTS
gobjTapiWithEvents = gobjTapi
Dim fOwner As Boolean, fMonitor As Boolean
Dim lMediaTypes As Long, lCallbackInstance As Long
fOwner = True
fMonitor = False
lMediaTypes = TapiConstants.TAPIMEDIATYPE_AUDIO
lCallbackInstance = 1
glRegistrationToken = gobjTapi.RegisterCallNotifications( _
gobjAddress, _
fMonitor, _
fOwner, _
lMediaTypes, _
lCallbackInstance)
End Sub
Public Sub InstallListener()
End Sub
Private Sub gobjTapiWithEvents_Event(ByVal TapiEvent As
TAPI3Lib.TAPI_EVENT,
ByVal pEvent As Object) Handles gobjTapiWithEvents.Event
If TapiEvent = TAPI_EVENT.TE_CALLNOTIFICATION Then
Dim objCallNotificationEvent As ITCallNotificationEvent
objCallNotificationEvent = pEvent
Dim gobjReceivedCallInfo As ITCallInfo
gobjReceivedCallInfo = objCallNotificationEvent.Call
Dim objCallControl As ITBasicCallControl
objCallControl = gobjReceivedCallInfo
objCallControl.Answer()
End If
End Sub
End Class
还有一个通过回调实现
VOID FAR PASCAL MessageCallback(DWORD hDevice, DWORD dwMsg,
DWORD dwCallbackInstance, DWORD dwParam1,
DWORD dwParam2, DWORD dwParam3)
{
bMessageCallBack = true;
printf("%u/t%u/t%u/n",dwMsg,dwCallbackInstance,dwParam1);
if (dwMsg == LINE_CALLINFO)
{
if (dwParam1 == LINECALLINFOSTATE_CALLERID)
{
LONG Res;
char *pCallInfo = new char[1024];
LINECALLINFO *CallInfo = reinterpret_cast<LINECALLINFO*>(pCallInfo);
CallInfo->dwTotalSize = 1024;
//Res = lineGetCallInfo(reinterpret_cast<HCALL>(hDevice), CallInfo);
Res = lineGetCallInfo((HCALL)hDevice, CallInfo);
char *CalledID = &pCallInfo[CallInfo->dwCallerIDOffset];
printf("CallerID : %s/n",
&pCallInfo[CallInfo->dwCallerIDOffset]);
delete[] CallInfo;
}
}
}
以上程序都是在TAPI3.0下做的。