PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : TAPI eingehende Telefonnummer auslesen


mea-_-culpa
2005-07-26, 11:22:13
Hallo Leute, hat jemand von euch vielleicht schon Erfahrungen sammeln können, wie man die Telefonnummer eines eingehenden Anrufers auslesen kann.

In meinem Fall ist das Telefon direkt am PC über die USB-Schnittstelle angeschlossen.

Ich habe von TAPI gar keinen Plan und weiß auch nicht recht, wie ich die Sache anfangen soll.

Also wenn Ihr für mich Beispiel-Sourcen oder andere gute Tips für micht habt... dann wäre ich froh wenn ihr sie hier posten könntet.

Danke im Vorraus

Katano
2005-07-26, 13:13:58
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tapi/tapi3/microsoft_telephony_overview.asp

dokumentation der Microsoft TAPI.

nähere Hilfe bekommst du evtl. wenn du noch angibts in welcher Programmiersprache und welche TAPI du benutzt. Das Grundgerüst von MS ist gleich, aber der Herstller hat noch genug schrauben zum dran drehen.

mea-_-culpa
2005-07-26, 13:36:50
Also als Programmiersprache würde ich VB bevorzugen und was die TAPI betrifft, würde ich am liebsten die von M$ verwenden. Es ist jetzt bloß die Frage, ob ich mit der M$ TAPI auch andere Telefone ansprechen kann z.B. Siemens usw.

Es muss doch auch möglich sein, sich nicht an Herstellern festzulegen. Oder?

Der Dialer von Windows, funktioniert ja auch mit jedem angeschlossenden Telefon; vorraus gesetzt, das der Treiber installiert ist. Ich würde sogar davon ausgehen, dass der Windows-Dialer auch die M$-Tapi benutzt.

Katano
2005-07-26, 14:16:27
ja ist es, da man bei einer API ja Funktionen für alles hat.

ich glaube hier findest du den Code schnipsel den du suchst. auch in VB
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tapi/tapi3/receive_a_call.asp

mea-_-culpa
2005-07-26, 16:13:39
Ich hab mich mal auf die MSDN-Seite umgeschaut und mir den Code ein bisschen zusammen kopiert.

Bekomme aber leider eine Fehlermeldung bei der Methode 'RegisterCallNotification', keine Ahnung warum

Hier ist der 'Testcode'
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
'Option Explicit

'Usually declared globally
Dim WithEvents gobjTapiWithEvents As TAPI
Dim glRegistrationToken As Long

Private Sub Command1_Click()

' Set error handling routine
' On Error GoTo MyErrorRoutine

'Usually declared globally
Dim gobjTapi As TAPI
'pick up the collection of Address objects
Dim gobjAddress As ITAddress
Dim objCollAddresses As ITCollection
Dim bFound As Boolean
Dim indexAddr As Long
Dim objCrtAddress As ITAddress

'Usually performed during form load
'Create the tapi object.

Set gobjTapi = New TAPI

'Call Initialize before calling any other TAPI function.
Call gobjTapi.Initialize

Set objCollAddresses = gobjTapi.Addresses

' Set error handling routine
' On Error GoTo MyErrorRoutine

'find address that supports the desired type, nSelectedType
bFound = False
nSelectedType = TAPIMEDIATYPE_AUDIO
For indexAddr = 1 To objCollAddresses.Count
Set objCrtAddress = objCollAddresses.Item(indexAddr)
Set objMediaSupport = objCrtAddress
Set objAddressCapabilities = objCrtAddress


If objMediaSupport.QueryMediaType(nSelectedType) Then
bFound = True
End If

Set objAddressCapabilities = Nothing
Set objMediaSupport = Nothing
Set objCrtAddress = Nothing

If bFound = True Then Exit For
Next indexAddr

If bFound = False Then
Exit Sub
End If

Set gobjAddress = objCollAddresses.Item(indexAddr)

'If no errors occurred, gobjAddress is now a usable address.

' Set error handling routine
' On Error GoTo MyErrorRoutine

'Usually performed at the same time
'as TAPI initialization
Const TAPI3_CALL_EVENTS = _
TE_CALLMEDIA Or _
TE_CALLNOTIFICATION Or _
TE_CALLSTATE

'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

' -> Hier Bekomme ich die Fehlermeldung
'Die Methode 'RegisterCallNotifications' für das Objekt 'ITTAPI' ist 'fehlgeschlagen

glRegistrationToken = gobjTapi.RegisterCallNotifications( _
gobjAddress, _
fMonitor, _
fOwner, _
lMediaTypes, _
lCallbackInstance)

' Set error handling routine
' On Error GoTo MyErrorRoutine

' pEvent is an IDispatch pointer for the
' ITCallNotificationEvent interface of the
' call object created by TAPI, and is passed
' into the event handler by TAPI.
If TapiEvent = TE_CALLNOTIFICATION Then
' Get the ITCallNotification interface.
Dim objCallNotificationEvent As ITCallNotificationEvent
' pEvent =
Set objCallNotificationEvent = pEvent

'query ITCallInfo interface for the new call, and store it
Dim gobjReceivedCallInfo As ITCallInfo
Set gobjReceivedCallInfo = objCallNotificationEvent.Call

' Get the ITBasicCallControl interface.
Dim objCallControl As ITBasicCallControl
Set objCallControl = gobjReceivedCallInfo

' Create the required terminals for this call.
' See the Select a Terminal code example.

'Answer
objCallControl.Answer
End If
End Sub

-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

Ähm... vielleicht könnt ihr mir ja weiterhelfen, würde mich freuen

Katano
2005-07-27, 10:39:07
bin kein VB experte, aber du hast der Methode einen Parameter zu wenig Übergeben.
der hier fehlt:

plRegister
[out] On success, the returned value that is used by ITTAPI::UnregisterNotifications.
Return Values
Value Meaning
S_OK Method succeeded.
E_POINTER The plRegister parameter is not a valid pointer.
TAPI_E_NOT_INITIALIZED The TAPI object has not been initialized.
E_OUTOFMEMORY Insufficient memory exists to perform the operation.

hier nachzulesen: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tapi/tapi3/ittapi_registercallnotifications.asp

ich vermute daran kann es liegen, und wenn nicht, erfährst du über den Return Code zumindest woran es liegt.

mea-_-culpa
2005-07-28, 18:01:03
Wie der Fehler 'RegisterCallNotification' ausgelöst wird habe ich jetzt gefunden.
Ich bekomme die Fehlermeldung, weil bei der Funktion:

-_-_-_-_-_CODE-_-_-_-_-_-_
Set objCollAddresses = gobjTapi.Addresses

nSelectedType = TAPIMEDIATYPE_AUDIO
For indexAddr = 1 To objCollAddresses.Count

If objMediaSupport.QueryMediaType(nSelectedType) Then
bFound = True
End If

If bFound = True Then Exit For
Next indexAddr
-_-_-_-_-_CODE ENDE-_-_-_-_-_-_

die erste TAPI 'Adresse' vom Typ 'TAPIMEDIATYPE_AUDIO' zurückgibt. In meinem Fall war es aber kein Telefon was hinter der Adresse war sondern die IPCONF-Leitung der Microsoft Multicastkonferenz. Keine Ahnung wozu die genau gut ist.
Kann man die Funktion vielleicht erweitern, dass sie nur Telefone zurückgibt?

Für alle die ähnliche Probleme wie ich haben und sich Fragen wie ich herraus gefunden habe welches Gerät sich hinter welche 'Tapi-Adresse' verbirgt, kann ich nur den Tapi-Tester von der Seite http://www.shrinkwrapvb.com empfehlen. Hier ist nochmal der genaue Link zum Tapi-Tester http://www.shrinkwrapvb.com/tapi_src.zip (VB-Sourcen)

Probleme habe ich jetzt noch bei der Variable 'TapiEvent' und des 'pEvent' Pointers.
Diese sind im Beispielskript auf der MS-Seite http://msdn.microsoft.com/library/d...eive_a_call.asp verwendet worden, ohne das ich jetzt einfach nachvollziehen kann wo diese Variablen definiert und initialisiert werden. Wäre schön wenn du mir wieder einen kleinen Hinweis dazu geben könntes Katano.

Katano
2005-07-29, 08:42:46
hmm, also du müsstest am einfachsten diese if abfrage erweitern:
If objMediaSupport.QueryMediaType(nSelectedType) Then
bFound = True
End If

so das die checkt obs ein telefon ist. den source dazu müsstest ja in dem tapi-tester finden.


pEvent:
' pEvent is an IDispatch pointer for the
' ITCallNotificationEvent interface of the
' call object created by TAPI, and is passed
' into the event handler by TAPI.
müsste also
Dim pEvent As IDispatch
(look: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tapi/tapi3/itcallnotificationevent.asp)

und TAPIEvent
schau ma hier: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tapi/tapi3/tapi_event.asp
und hier: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tapi/tapi3/ittapieventnotification_event.asp

hoffe das hilft...