Passing Cluster Containing Strings in C DLL as Struct

Updated Aug 31, 2023



  • LabVIEW

I am using Call Library Function Node in LabVIEW to call functions from a DLL. One of the parameters is a struct that contains a string. How do I pass a LabVIEW cluster in a format that the Call Library Function Node will accept? Will I need to create a .lsb file for use with the code interface node (CIN) in LabVIEW?

You will not need to create a .lsb file. The recommended method of handling structs with strings with Call Library Function Node is as follows:

1. Use DSNewPtr, MoveBlock to allocate string in LabVIEW, copy contents into allocated space. These functions are accessible via Call Library Function Node, set library to LabVIEW.
2. Use Call Library Function Node to call function in C DLL. Pass cluster in, use Adapt to Type and Pointers to Handles.
3. Dispose of allocated string in LabVIEW with DSDisposePtr.

Additional Information

See the community forum discussion Solved: Passing Cluster Containing Strings in C DLL as Struct for example code and further discussion.