Example Code

Calling LabVIEW DLL in Visual C++ That Passes Array Handles by Reference

Code and Documents

Attachment

Overview


This example demonstrates the syntax necessary for passing array handles between an external coding environment and a shared library (DLL) you create in LabVIEW. Array_Multiply.vi has an input array and an output array. The VI generates the output array by multiplying each element of the input array by two. A build script, Build Array_Multiply.bld, builds the VI into a shared library that passes these parameters as array handle pointers. Array_Multiply.lib and Array_Multiply.h are the library and header files that the build creates.

The Call Array_Multiply DLL folder contains the files for the workspace of the same name, as well as the Array_Multiply.dll. The main code of the project allocates memory for the handle pointers and initializes the arrays to which they point.

Note: To make the example as simple as possible, each array contains only one element.

Print statements write the value of the first element of the output array to a console before and after a call to the shared library. You will see that the call to the shared library changes the value of the output array.

Note: You might need to reattach labview.lib to the project. You can find this file in the labview\cintools directory.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors