Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question#include <windows.h> typedef struct { long x; BSTR chaine; } data; int __stdcall FillArr(data *inArr) { MessageBox(NULL, (char*)inArr[0].chaine, "Titre", MB_OK); inArr[0].x = 10; SysFreeString(inArr[0].chaine); inArr[0].chaine = SysAllocStringByteLen("1234", 4); return 1; }
Private Type Data x As Long chaine As String End Type Private Declare Function FillArr Lib "test.dll" (ByRef inArr As Data) As Long Private Sub Command_Click() Dim tableau(0 To 2) As Data tableau(0).x = 1 tableau(0).chaine = "titi" tableau(1).x = 1 tableau(1).chaine = "titi" tableau(2).x = 1 tableau(2).chaine = "titi" FillArr tableau(0) MsgBox tableau(0).x MsgBox tableau(0).chaine End Sub
gcc -Wall -ansi -pedantic -c test.c -o test.o gcc -Wall -ansi -pedantic -shared -Wl,--kill-at test.c -o test.dll -loleaut32
#include <windows.h> typedef struct { long x; BSTR chaine; } data; int __stdcall FillArr(data *inArr) { MessageBoxW(NULL, inArr[1].chaine, L"Titre", MB_OK); inArr[1].x = 10; SysReAllocString(&inArr[1].chaine, L"1234"); return 1; }
gcc -Wall -ansi -pedantic -shared -Wl,--kill-at test.c -o test.dll -loleaut32
Private Type Data x As Long chaine As String End Type Private Declare Function FillArr Lib "test.dll" (ByVal inArr As Long) As Long Private Sub Command_Click() Dim tableau(0 To 2) As Data tableau(0).x = 1 tableau(0).chaine = "titi" tableau(1).x = 1 tableau(1).chaine = "titi" tableau(2).x = 1 tableau(2).chaine = "titi" FillArr VarPtr(tableau(0)) MsgBox tableau(1).x MsgBox tableau(1).chaine End Sub
Private Structure Data Dim x As Long Dim chaine As InPtr End Structure