[VB] Tapi en dialing rules

Pagina: 1
Acties:

  • JapJap
  • Registratie: Maart 2001
  • Laatst online: 07-01 11:02
Ik gebruik code uit het programma van http://www.shrinkwrapvb.com/vbtapi.htm om te bellen in mijn applicatie. Het mooie van dit stukje code is dat de Windows Phone Dialer niet gestart wordt om te bellen, wat bij de meeste (alle) andere VB Tapi programma's wel het geval is.

Het enige probleem is dat het programma geen rekening houdt met de opgegeven Dialing Rules in Windows. Na lang zoeken weet ik inmiddels dat daarvoor de API functie lineTranslateAddress gebruikt kan worden, maar ik kan hier helaas geen VB voorbeeld van vinden.

Ik heb wel een stukje PowerBasic (?) code gevonden wat gebruik maakt van de lineTranslateAddress functie en met wat kleine aanpassingen heb ik dit vertaald naar VB. Ik krijg echter een Overflow error bij het aanroepen van de lineTranslateAddress functie:
Visual Basic:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Public Function ProcessCanonical(ByVal phonenumber As String) As String
    
    'A common practice is that phone numbers are stored in canonical format,
    'which includes international the dialing code, area code, and so forth. An
    'actual call may use a modified form of this number depending on current
    'location, local or long distance call, and so forth. Therefore, the
    'initial phone number should be translated into a dialable form. To proceed
    'with this task, you need to call lineTranslateAddress. Similar to
    'lineGetDevCaps, you might be required to call this function several times
    'until a correctly sized memory block is passed to keep its output.
    
    'the canonical address format is:
    ' + Country/RegionCode ( AreaCode ) SubscriberNumber
    
    'For example, this is how you would enter a US number in canonical address format:
    '+1 (425) 555-0100
    
    
    Dim RetVal As Long
    Dim NumElem As Long
    Dim TrnsAdd() As LINETRANSLATEOUTPUT
    
    NumElem = 1 ' Starting memory size
    ReDim TrnsAdd(NumElem - 1) ' First attempt
    TrnsAdd(0).dwTotalSize = Len(TrnsAdd(0)) * 4 * NumElem ' Size of the UDT

    Do
        'De volgende regel geeft de Overflow Error:
        RetVal = lineTranslateAddress(m_hLineApp, m_CurLineID, m_ApplicationVersion, phonenumber, 0, 0, TrnsAdd(0))   ' Translate
        
        If RetVal = LINEERR_STRUCTURETOOSMALL Or TrnsAdd(0).dwTotalSize < TrnsAdd(0).dwNeededSize Then ' increase buffer size
            
            NumElem = NumElem + 1
            
            If NumElem > 20 Then ' Something else is wrong
                ProcessCanonical = "Memory increased x" + str$(NumElem) + " and still not big enough for TrnsAdd!"
                Exit Function
            End If
            
            ReDim TrnsAdd(NumElem - 1) ' assign more memory
            TrnsAdd(0).dwTotalSize = 10 * 4 * NumElem
        Else 
            Exit Do
        End If
    Loop

End Function


De variabelen m_hLineApp, m_CurLineID en m_ApplicationVersion zijn globale variabelen die ik ook in andere functies gebruik. Iemand enig idee wat ik fout doe?

  • farlane
  • Registratie: Maart 2000
  • Laatst online: 18-04 23:33
Zet in je opties break on all errors aan en kijk waar het fout gaat zou ik zeggen

Somniferous whisperings of scarlet fields. Sleep calling me and in my dreams i wander. My reality is abandoned (I traverse afar). Not a care if I never everwake.


  • JapJap
  • Registratie: Maart 2001
  • Laatst online: 07-01 11:02
Bedankt, maar ik weet al waar het fout gaat: regel 29 van de code hierboven.

Misschien dat iemand een ingeving krijgt door onderstaande code:
Visual Basic:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Public Type LINETRANSLATEOUTPUT

    dwTotalSize As Long
    dwNeededSize As Long
    dwUsedSize As Long

    dwDialableStringSize As Long
    dwDialableStringOffset As Long
    dwDisplayableStringSize As Long
    dwDisplayableStringOffset As Long

    dwCurrentCountry As Long
    dwDestCountry As Long
    dwTranslateResults As Long

End Type

Declare Function lineTranslateAddress Lib "tapi32.dll" Alias "lineTranslateAddressA" _
    (ByVal hLineApp As Integer, _
    ByVal dwDeviceID As Long, _
    ByVal dwAPIVersion As Long, _
    ByVal lpszAddressIn As String, _
    ByVal dwCard As Long, _
    ByVal dwTranslateOptions As Long, _
    ByRef lpTranslateOutput As LINETRANSLATEOUTPUT)

  • JapJap
  • Registratie: Maart 2001
  • Laatst online: 07-01 11:02
*kick*

  • farlane
  • Registratie: Maart 2000
  • Laatst online: 18-04 23:33
Als de datatypes die je bij de aanroep allemaal kloppen ( overflow wil zeggen dat een waarde niet in een datatype past ) zou ik de declare regel nog eens goed bekijken.

Je declared een functie zonder return waarde, en dan maakt VB er volgens mij een variant van. Het lijkt me niet dat het orgineel van die functie een variant returned.

Somniferous whisperings of scarlet fields. Sleep calling me and in my dreams i wander. My reality is abandoned (I traverse afar). Not a care if I never everwake.


  • JapJap
  • Registratie: Maart 2001
  • Laatst online: 07-01 11:02
Bedankt voor je hulp, maar dat was het helaas niet. Ik heb hier de code staan mocht iemand er een blik op willen werpen.

En een plaatje doet altijd wonderen:

;)

[ Voor 10% gewijzigd door JapJap op 01-09-2021 16:59 ]


  • JapJap
  • Registratie: Maart 2001
  • Laatst online: 07-01 11:02
Nog een laatste kickje...

Ik heb inmiddels vanalles geprobeerd en overal gezocht, maar ik kom er nog niet uit.
Hulp wordt zeer op prijs gesteld! :/

  • farlane
  • Registratie: Maart 2000
  • Laatst online: 18-04 23:33
Als je de declare regel naar het volgende verandert:

Visual Basic:
1
2
3
4
5
6
7
8
Declare Function lineTranslateAddress Lib "tapi32.dll" ( _ 
     ByVal hLineApp As Long, _ 
     ByVal dwDeviceID As Long, _ 
     ByVal dwAPIVersion As Long, _ 
     ByVal lpszAddressIn As String, _ 
     ByVal dwCard As Long, _ 
     ByVal dwTranslateOptions As Long, _ 
     ByRef lpTranslateOutput As LINETRANSLATEOUTPUT) As Long



Krij ik niet meer de overflow. Eerste parameter is een Long, geen integer. Hence the overflow :)

( Btw, deze declare heb ik met de Apiviewer 2003 gemaakt. Deze is ergens te downloaden :) )

Somniferous whisperings of scarlet fields. Sleep calling me and in my dreams i wander. My reality is abandoned (I traverse afar). Not a care if I never everwake.


  • JapJap
  • Registratie: Maart 2001
  • Laatst online: 07-01 11:02
|:(
Tjezus, wat stom...

Heel erg bedankt Farlane!

  • pkouwer
  • Registratie: November 2001
  • Laatst online: 07-10-2025
gebruik je het ook voor inkomende gesprekken ? Ben l. nog op zoek naar zoiets;
Pagina: 1