Bonjour à tous,
J'ai beaucoup de problèmes pour implémenter une dll via PB9. Il semblerait que ce soit un problème de typage, mais je ne parviens pas à le résoudre.
Voici la déclaration du point d'entrée de la dll :
Voici un exemple sous vb.net qui fonctionne :
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
20
21
22
23
24
25
26
27
28 extern "C" __declspec(dllexport) double calc_planifier( char* val1, usint val2, usint val3, usint val4, usint val5, usint val6, usint* val7, double val8, usint val9, char* val10, double* val11, usint val12, usint* val13, uchar* val14, usint val15, usint val16, usint val17, double *val18, double* val19, double* val20, usint val21, usint val22, double* val23=0, double* val24=0, double *val25=0, )
Le même sous PB9 qui ne fonctionne pas :
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
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109 Declare Function Calc _ Lib "ma.dll" _ Alias "mafonction" ( _ ByRef val1 As String, _ ByVal val2 As Short, _ ByVal val3 As Short, _ ByVal val4 As Short, _ ByVal val5 As Short, _ ByVal val6 As Short, _ ByRef val7() As Short, _ ByVal val8 As Double, _ ByVal val9 As Short, _ ByRef val10 As String, _ ByRef val11() As Double, _ ByVal val12 As Short, _ ByRef val13() As Short, _ ByRef val14 As String, _ ByVal val15 As Short, _ ByVal val16 As Short, _ ByVal val17 As Short, _ ByRef val18() As Double, _ ByRef val19() As Double, _ ByRef val20() As Double, _ ByVal val21 As Short, _ ByVal val22 As Short, _ ByRef val23() As Double, _ ByRef val24() As Double, _ ByRef val25() As Double _ ) _ As Double Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim v1 As String Dim v2, v3, v4, v5, v7(), v13(), v6, v9, v12, v15, v16, v17, v21, v22 As Short Dim v8, v11(), v18(), v19(), v20(), v23(), v24(), v25() As Double Dim v10, v14 As String Dim ret As Double = 0 v1 = "C:\001.aud" + Chr(0) v2 = 100 v3 = 3 v4 = 2 v5 = 5 v6 = 1 ReDim v7(4) v7(0) = 1 v7(1) = 2 v7(2) = 3 v7(3) = 4 v8 = 0.3 v9 = 1 v10 = "((SEX=3)&(AGE=4-6));" + Chr(0) ReDim v11(4) v11(0) = 1 v11(1) = 2 v11(2) = 3 v11(3) = 4 v12 = 2 ReDim v13(v12) v13(0) = 1 v13(1) = 2 v14 = "" + Chr(0) v15 = 1 v16 = 1 v17 = 17 ReDim v18(5) v18(0) = 181 v18(1) = 182 v18(2) = 183 v18(3) = 183 v18(4) = 184 ReDim v19(5) v19(0) = 191 v19(1) = 192 v19(2) = 193 v19(3) = 194 v19(4) = 195 ReDim v20(3) v20(0) = 201 v20(1) = 202 v20(2) = 203 v21 = 11 v22 = 51 ReDim v23(v21) For i As Integer = 0 To v21 - 1 v23(i) = 0 Next ReDim v24(v22) For i As Integer = 0 To v22 - 1 v24(i) = 0 Next ReDim v25(2) v25(0) = 0 v25(1) = 0 Try ret = Calc(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) Label2.Text = ret Label6.Text = v24(0) Label7.Text = v25(0) Label8.Text = v25(1) Catch ex As Exception MessageBox.Show("erreur") End Try End Sub
En Global External Functions
Sur un event d'un bouton
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
20
21
22
23
24
25
26
27 FUNCTION double mafonction( & REF string val1, & ulong val2, & ulong val3, & ulong val4, & ulong val5, & ulong val6, & REF ulong val7[4], & double val8, & ulong val9, & REF string val10, & REF double val11[4], & ulong val12, & REF ulong val13[2], & REF string vcl14, & ulong val15, & ulong val16, & ulong val17, & REF double val18[5], & REF double val19[5], & REF double val20[3], & ulong val21, & ulong val22, & REF double val23[11], & REF double val24[51], & REF double val25[2] & ) LIBRARY "ma.dll"
J'obtiens l'erreur suivante : "Error : Specified argument type differ from required type at runtime in DLL finction mafonction. (invalid stack pointer on return from function call) at line 64 in ue_calldll of object w_main."
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
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 string v1 ulong v2, v3, v4, v5, v7[4], v13[2], v6, v9, v12, v15, v16, v17, v21, v22 double v8, v11[4], v18[5], v19[5], v20[3], v23[11], v24[51], v25[2] string v10, v14 double ret = 0 integer i v1 = "C:\001.aud" + Char(0) v2 = 100 v3 = 3 v4 = 2 v5 = 5 v6 = 1 v7[1] = 1 v7[2] = 2 v7[3] = 3 v7[4] = 4 v8 = 0.3 v9 = 1 v10 = "((SEX=3)&(AGE=4-6));" + Char(0) v11[1] = 1 v11[2] = 2 v11[3] = 3 v11[4] = 4 v12 = 2 v13[1] = 1 v13[2] = 2 v14 = "" + Char(0) v15 = 1 v16 = 1 v17 = 17 v18[1] = 181 v18[2] = 182 v18[3] = 183 v18[4] = 183 v18[5] = 184 v19[1] = 191 v19[2] = 192 v19[3] = 193 v19[4] = 194 v19[5] = 195 v20[1] = 201 v20[2] = 202 v20[3] = 203 v21 = 11 v22 = 51 For i = 1 To integer(v21) v23[i] = 0 Next For i = 1 To integer(v22) v24[i] = 0 Next v25[1] = 0 v25[2] = 0 ret = mafonction(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) sle_1.Text = string(ret) sle_2.Text = string(v24[0]) sle_3.Text = string(v25[0]) sle_3.Text = string(v25[1])
Je n'ai pas la moindre idée du problème
Edit 1 : Ajout du code erreur.
Edit 2 : Ajout du point d'entrée de la dll.
Partager