Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass a user defined type to an Api function?

Status
Not open for further replies.

ATHUEL

Technical User
Sep 23, 2002
29
US
Hi all,
I´m facing this problem with an Api function:
the function is something like this:( in c++)

bool someFunction ( LPDest Dest, hFile HandleFile)

( translated to vb from c++)

public someFunction( ByRef DestinationPointer as Any, ByVal HandleToFile as long ) as boolean

the intendeed functionality according to the specification is as follow:

DestinationPointer: is a pointer to a structure ( or user defined type) that is filled by the function.

HandleToFile: handle to the file from where the data to fill the user defined type, is taken.

The function returns TRUE on success, False on error.

So what i´ve done so far is:

1- I create an UDT of the form

Public Type UDT
X as Double
Y as Double
Z as double
End Type


2- I create a reference to that UDT

Dim someUDT as UDT

3- Call the function as:
public someFunction( someUDT, HandleToFile ) as boolean

At this point all seems to work, exept that the values I get in someUDT.X , someUDT.Y and someUDT.Z makes no sense.

even more, if I run this function more than once, i get diferent results for every data.

And here is where i´m stocked.

I was reading various post related to using pointers in VB but I don´t understand how to apply it to this particular case.
So any help would be greatly appreciated.

 
Instead of posting > public someFunction( ByRef DestinationPointer as Any, ByVal HandleToFile as long ) as boolean
Could you post the actual function.
[neutral]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top