How to pass UDT to a C++ DLL which contains Arrays
My problem is,
UDT:
public Type mwin6_tbl
kda(69) as string * 84
KMax as Integer
kdax as string * 319
kdl as Integer
kpl as Integer
kpl2 as Integer
kxpc as Integer
kbnflg as string * 2
posflg as Integer
jobflg as Integer
endflg as Integer
null as string * 1
End Type
public mwin6 as mwin6_tbl
public const mwin6Size = 5218 '(This value I want to know exactly how many bytes -the above UDT)
Declare Function msetenv Lib "c:\windows\system\AUTOCALC.DLL" (win6 as Byte) as Integer
Declare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMemory" ( lpvDest as Any, lpvSource as Any, byval cbCopy as Long)
Declare Function msetyouind Lib "c:\windows\system\AUTOCALC.DLL" (ind1 as
Byte) as Integer
public sub mysub()
Ret% = Fmsetyouind()
End Sub
public Function Fmsetyouind() as Integer
Dim mwin6byte() as Byte
ReDim mwin6byte(mwin6Size) as Byte
CopyMemory mwin6byte(0), mwin6, mwin6Size
Ret% = msetyouind(mwin6byte(0))
CopyMemory mwin6, mwin6byte(0), mwin6Size
If Ret% = 0 then ER% = 1: GoTo ERMSG1
Fmsetyouind = 1
ERMSG1:
Exit Function
End Function
But my code is giving error. VB is geting crashed soon after accessing the DLL.
Can you please help me out how to solve my problem, I am already crossed my deadline of the project.
Ramaswamy
Re: How to pass UDT to a C++ DLL which contains Arrays
Using the LenB command in VB gives 12420 bytes i.e.:
private Type mwin6_tbl
kda(69) as string * 84
KMax as Integer
kdax as string * 319
kdl as Integer
kpl as Integer
kpl2 as Integer
kxpc as Integer
kbnflg as string * 2
posflg as Integer
jobflg as Integer
endflg as Integer
null as string * 1
End Type
private Sub Form_Load()
Dim x as mwin6_tbl
Debug.print LenB(x) & " bytes "
End Sub
HTH,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com