LabVIEW strings are not null-terminated C-style strings. LabVIEW strings are similar to Pascal-style strings in the sense that the first four bytes contain the length of the string.
There are two ways to take a LabVIEW string and pass it to a DLL that is expecting a char * (pointer to character array). The most common method is to define the function parameter as a
CStr. When you place a Call Library Function Node on the block diagram, double-click it to specify the prototype of the function you want to call. Here you will specify the parameter to be type
String and the format to be
C String Pointer. Notice how the prototype displays the data type
CStr. This data type is equivalent to
char *.
If you are working with string-based instrument control, it may be easier to pass an array of 8-bit integers than C strings because of the possibility of NULL values in the string. When you place a Call Library Function Node, double-click it to specify the prototype of the function you want to call. The key here is to specify the parameter type as
Array and its data type as
Unsigned 8-bit Integer. The dimension of the array is
1 and the format is
Array Data Pointer. In LabVIEW you must convert the string to a byte array using the
String to Byte Array.vi.