PDA

Click to See Complete Forum and Search --> : Passing Array handel in UDT to DLL


Shaii
Dec 12th, 1999, 06:56 PM
I have a function in a c++ dll that gets a pointer to double array. inside a struct.
I defined a UDT in VB5 and passed all the rest of the UDT fields fine, the problem is with this array.
type Type1
par1 as Integer
myArr as double
end type
dim myType as Type1 , arr() as double
ReDim arr(1000)

I don't know how to set myType.myArr to point to arr


if I pass the array seperetly it's easy and it works but I need it in the UDT.
CALL dllfunction(myType,arr(0))

Is this posible???
HELP
Shai

Aaron Young
Dec 12th, 1999, 08:10 PM
Why don't you Dim the UDT variable directly?, eg.

Type Type1
Par1 As Integer
myArr() As Double
End Type

Dim myType As Type1
ReDim myType.myArr(1000)



------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net

Shaii
Dec 12th, 1999, 10:41 PM
I have tried this with no success.
I don't know if this is my fault or it's not the right way.

I will make myself clear.
the dll is waiting for a UDT with a pointer to a double array.

???????????????????????

Aaron Young
Dec 13th, 1999, 11:24 AM
I see, you want to pass a pointer, not the actual array..

In that case your only option would be to use one of the Undocumented and Unsupported Pointer Functions in VB, like VarPtr() to give you the Pointer to a Local Array which you can store as a part of a User Defined Type.

Something like:

Type Type1
par1 As Integer
myArr As Long
End Type

Dim myType As Type1
Dim Arr(1000) As Double

myType.myArr = VarPtr(Arr(0))


------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net

Shaii
Dec 14th, 1999, 09:13 PM
10x for the help VarPtr() is working fine!

Shai