
VB3.0 - How do I assign a pointer to a structure to a VB variable?
Easier than in my previous answer :
Module1.bas
Declarations
Declare Sub hmemcpy Lib "kernel" (hpvDest As Any, ByVal hpvSource As
String, ByVal cbCopy As Long)
Type mystruct
string1 As String * 10
string2 As String * 20
End Type
Global mystructvar As mystruct
Global mystring As String * 30
------------------------------------------------
Form1
Sub Command1_click()
mystring = "123456789012345678901234567890"
Call hmemcpy(mystructvar, ByVal mystring, ByVal 30)
Print mystructvar.string1
Print mystructvar.string2
End Sub
In this example, the contents of mystring is copied to mystructvar, in your
case, you must declare the function as follows :
Declare Sub hmemcpy Lib "kernel" (hpvDest As Any, ByVal YourStructPointer
As Long, ByVal cbCopy As Long)
(cbCopy is the number of bytes to copy)
and your call must be :
Call hmemcpy(mystructvar, ByVal YourStructPointer, ByVal nBytes)
Obviously, YourStructPointer is the pointer you have obtained calling your
dll.
Good luck,
Nacho.