Bonjour,

Je souhaite faire migrer une application écrite en VB.6 vers VB.net.
J'ai un souci lors de l'utilisation d'une fonction d'une DLL.

Voici sa description sous VB.6 :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
Public Type tProtProperty
  ProtType  As Long                          'Type of Protocol (tProt)
  TimeOut As Long                           'ALL protocols
  Baudrate As Long                          'ANSI, HSP5
  Comport As Long                           'ANSI, HSP5
  Flag As Long                                   'ANSI, HSP5: 01 = Sendslow  / IP: 01 = UDP
  Port As Long                                   'IP:Port number
  Txtlen As Byte                                'IP : length of following text or 0
  txt As String * 100                          'IP : IP-Address or name (maximum length)
End Type
 
 
 
    Declare Sub getprotproperties Lib "protkeb.DLL" (ByVal ctrl As Any)
 
    Public ProtProperty As tProtProperty
    Call getprotproperties(ProtProperty)   'readout all settings
Le passage à VB.net réalisé et le suivant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
    Public Structure tProtProperty
        Public ProtType As Integer                          'Type of Protocol (tProt)
        Public TimeOut As Integer                           'ALL protocols
        Public Baudrate As tBaudRate                          'ANSI, HSP5
        Public Comport As Integer                           'ANSI, HSP5
        Public Flag As Integer                                   'ANSI, HSP5: 01 = Sendslow  / IP: 01 = UDP
        Public Port As Integer                             'IP:Port number
        Public Txtlen As Byte                                'IP : length of following text or 0
        Public txt() As Byte  '????????
    End Structure
 
    Declare Sub getprotproperties Lib "protkeb.DLL" (ByRef prottype As Integer, ByRef timeout As Integer, ByRef baudrate As tBaudRate, ByRef comport As Integer, ByRef flag As Integer, ByRef port As Integer, ByRef txtlen As Byte, ByRef txt() As Byte)
 
    Public ProtProperty As tProtProperty
 
 
 
    getprotproperties(ProtProperty.ProtType, ProtProperty.TimeOut, ProtProperty.Baudrate, ProtProperty.Comport, ProtProperty.Flag, ProtProperty.Port, ProtProperty.Txtlen, ProtProperty.txt)   'readout all settings

Le problème
se situe au niveau du passage du tableau (dernier élément de la structure), je n'ai pas trouvé de moyen de spécifier une taille fixe. J'ai utilisé quelques artéfacts (comme déclarer plusieurs Byte -> byte_1, byte_2...) dans ce cas j'arrive à récupérer mes données. Mais ce n'est pas envisageable si j'ai une centaine d'octets à récupérer. Le but étant de transmettre une chaîne de caractères. Dans l'exemple ci-dessus, seul le premier octet est récupéré.

Merci pour votre aide...