Passing an array from Visual Basic to a Delphi DLL
Posted on 1998-07-26
I am banking all of my points on asking this question... I really need to solve this problem!
I have written a DLL in Delphi 4.0. It compile successfully and I am able to call it and acces the procedure that I need in it from within VB.
Here is the code for the declaration of the procedure in Delphi:
myarray = array of double;
PROCEDURE myprocedure (rob : myarray;
width, height : integer;
ndimen, isign : integer); stdcall;
I pass it an array from within VB, but the as soon as I exit out of the DLL the changes are not saved to the array. (I have tried putting "VAR" in front of rob... but it did not solve the problem)
This is my DLL Declare in VB:
Declare Sub myprocedure lib "delphidll.dll" (ByRef junk as double,
ByVal wid as integer,
ByVal hgt as integer,
ByVal ndim as integer,
ByVal isign as integer)
I call the DLL as follows from VB:
ReDim sindata(1 To 256 * CLng(256)) As Double
i = 1
While (i < 256 * CLng(256))
sindata(i + 1) = Sin(i)
sindata(i) = 0
i = i + 2
myprocedure sindata(1, 1), 128, 256, 2, 1
I can debug the DLL from within Delphi once the VB app is compiled into an EXE. I set breaks in the DLL, and I see that the DLL is populated correctly, and while the dll is running, the values in the array are changed, but the thing is this... once the dll is finished, then all of the changes are not retained... meaning once back in VB code, the array has the ORIGINAL values in it.
Can someone help me with this problem that I've got? If you would like more details about the problem email me: email@example.com and I'll be glad to send you the code for both the Delphi DLL and the VB App.
Thanks in advance!