|
-
December 18th, 1999, 06:57 AM
#1
Passing Array of structures to a DLL
1. How to pass an array of structures to a DLL and retrieve back the values ?
2. How to type cast a user-defined type in VB ?
BRR
-
December 18th, 1999, 07:46 AM
#2
Re: Passing Array of structures to a DLL
1. Define the Function with "As Any"
Declare Function SomeDllFunc lib "SomeDll"( byref lpUdtAr as Any, byval nc as long) as long
Then call the function by passing the first element
dim pUdt(9) as UDTSTRUCT
lrtn = SomeDllFunc(pUDT(0),10) ' typically the second param telling how many valid elements in the array
2. Type Casting is to be implemented by making another copy actually. You can search the articles secttion to see how exactly it is done.
I presume you are refering to Function which return a pointer to a type..
Declare Function UdtReturningFunc Lib "Something" () as long
' get the declaration for RtlMoveMemory ( more famous as CopyMemory fn) . i dont remember off-hand.. something like..
Declare Sub CopyMemory lib "Kernel32" Alias "RtlMoveMemory" (lpDest as Any, lpSource as Any, lBytes as Long)
dim pUdt as SOmeUdt
dim lpudt as long
lpUdt = UdtReturningFunc ()
CopyMemory pUdt, byval lpUdt, len(pUdt)
' This is actually another copy of the data.. not
' not all that efficient as a Typecast
RK
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|