LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a LabVIEW 2D array to an LPVOID pointer of a DLL

Inside my LabVIEW code I have a 2D array of U8 that I need to pass to a windows DLL.
The DLL is expecting the data as a continous block of memory by means of a void pointer.   (LPVOID pBits)
 
I cannot immediately connect the array to the Call Library Function Node.
This will give me the error that I cannot connect and array data type to an element datatype.
I also believe this approach is wrong since I do not know how LV arrays are managed internally. The probably have some internal housekeeping stuff like the dimension size in both dimensions.
 
So the question is: How do I connect the 2D array to the void pointer of my array?
The void pointer expects the data from the array to be a continuous block of data.
 
Thanks in advance for all the help!
0 Kudos
Message 1 of 2
(2,859 Views)
Hi Noxus,
If you configure the CLF to accept an array for this parameter, the CLF will pass a pointer to the beginning of the data.  In LabVIEW, resize the 2D array so that it's 1D, and in the DLL, expect the data in row-major order.  That is, if the Array is 5 rows by 3 columns, then the first three elements of the resized array would represent the first row.
 
I think the DLL ('C"?) uses the same row-major memory organization as LabVIEW for multi-dimensioned array-data, it's possible you can access the second element of the first row as:
pBits[0][1] - assuming the 2D array "pBits" has been dimensioned identically as the 2Darray in LabVIEW.
 
Cheers. 
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 2 of 2
(2,831 Views)