VB3.0 - How do I assign a pointer to a structure to a VB variable? 
Author Message
 VB3.0 - How do I assign a pointer to a structure to a VB variable?

I am trying to call a DLL Function that returns a pointer to a structure
in VB3.0.

I have assigned the pointer value to a long but I can't find a way to
copy the
contents to the local declared 'Type' variable.  I have found several
references
to the Kernal32 function RtlMoveMemory, but this is a 16 bit
application.  If there
be a way I would appreciate any help on the matter.

Mark



Thu, 16 Dec 1999 03:00:00 GMT  
 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.



Fri, 17 Dec 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. assigning a returned pointer to a pointer in VB

2. Assigning a string pointer to a long variable

3. Problems calling a DLL with structure containing a string pointer in VB3.0

4. Creating a folder structure and then assigning permissions on that structure via script

5. call VC DLL with structure contains pointer of the structure to next

6. call VC DLL with structure contains pointer of the structure to next

7. Passing pointer to pointer to a structure to a WINAPI function

8. Pointer to pointer to structure / Returnvalue from API

9. Structured storage - done it using VB?

10. VB.net - Pointers of structures

11. How do I pass a VB Structure pointer to an OCX

12. HELP: Read a pointer structure from VB

 

 
Powered by phpBB® Forum Software