04-16-2016 05:38 AM
Hi, I'm aware there are plenty of threads around this topic, but there are a lot of variations and I've never used LabVIEW before, and I seem to be struggling at a very basic level, so I'm hoping someone can help me out with the very simple specific test case below to put me on the right track.
actually i am trying to allocate some memory in my dll code (using malloc function) ,and pass that memory location address from dll to labview.
in dll i placed some data in that location but in labview when i was trying to dereference the memory location i am not able to get the data what i placed.
for getting address i send a unsigned 64 bit integer from labview to dll function as a pointer to value .
and in c dll i just used pointer as argument to recieve this integer address and placed the memory location address in that interger address using pointer .
Thank you in advance
Solved! Go to Solution.
04-16-2016 11:36 AM
04-18-2016 08:13 AM
thank yo for your reply mike,
sry mike i don't know how to create DLL using labview, but here i am trying to get data from a flat panel he gave a C dll.
it consists a function has memory location as argument ,so i am using vc++ 6.0 for creating library which creates memory and pass to dll ,and then im trying to send the location from librery to labview for dereferencing data.
when i created memory using malloc function and returing that address to the labview.
in labview when i am trying to dereference that location i am getting garbage data.
04-18-2016 01:40 PM
@anil06 wrote:sry mike i don't know how to create DLL using labview, but here i am trying to get data from a flat panel he gave a C dll.
it consists a function has memory location as argument ,so i am using vc++ 6.0 for creating library which creates memory and pass to dll ,and then im trying to send the location from librery to labview for dereferencing data.
If I've understood correctly, you have a DLL you want to call. A function in that DLL expects a pointer to allocated memory as one of its parameters. You have created an additional DLL just to allocate memory, because you have not spent enough time reading through the LabVIEW help and posts on this forum to see that LabVIEW can allocate memory and pass a pointer to it simply by initializing an array of the correct number of bytes.
If you post your code, and the header (.h) file for the DLL you want to call, along with any documentation for that DLL, we can provide more specific help.
04-18-2016 02:57 PM - edited 04-18-2016 02:58 PM
Fiirst, as VC 6.0 doesn't support 64 bit code creation, you should definitely use a 32 bit entity as pointer, or if you use LabVIEW 2009 or newer (but why then such an old and unsupported C compiler?? ) then use the pointer sized datatype.
But without a lot more information from you as to the DLL source code and what you have done in LabVIEW so far (attach both the VIs and C source code of what you have done so far) we only can keep poking in the dark.
04-25-2016 07:43 AM
thank you nathand.
i tried what you said by creating an array with required size passed to the dll then it works.
thanks for your help.