Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / convenient way to access a structure returned from a dll function?

Author
Message
Xception
19
Years of Service
User Offline
Joined: 14th Mar 2005
Location:
Posted: 22nd Mar 2005 05:21
I pass a pointer of a memory area to the dll, copy the structure I want to return to that address, that's no problem.
But is there an easy way to access this structure now?
DBPRO does not allow me to copy the memory to a type.
Is there a workaround?
I know how to access this memory area, that is not the point, I just want to know a more convenient way to access it.
How do you return structures?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Mar 2005 06:37
Not really, no. The best way that I've found is to keep the structure held within the DLL, and provide access functions to get the data piece by piece.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
Daveh
19
Years of Service
User Offline
Joined: 30th Mar 2005
Location:
Posted: 1st Apr 2005 02:49
You can also use memblocks to reduce the number of functions needed for large structures with IanM's idea (which is good for small number of members).

For example your DLL code:


and your DB code to use this:



You do need to make sure the C compiler doesn't change your structure size which can happen if you use bytes or words (which is what the pragma pack does with MSVC, other compilers will have a similar command). It can also be tricky to properly unpack the memblock in DB, but you only have to do it once so it's no too bad.

Login to post a reply

Server time is: 2024-11-21 14:47:41
Your offset time is: 2024-11-21 14:47:41