Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are at least a few ways to return a string from a Call Library Function Node:</p> <ol> <li><p>Return a C string pointer from your DLL function, and configure the Call Library Function Node to have a return type of "C String Pointer". Note that the returned string must be valid after the function returns, so it can't be a pointer to a string allocated on the stack. It must be one of the following: allocated on the heap, statically allocated, a constant string literal, etc.</p> <p>It looks like <code>examples/dll/regexpr/Regular Expression Solution/VIs/Get Error String.vi</code> in the LabVIEW directory takes this approach.</p></li> <li><p>Allocate a string in your VI, pass it to the Call Library Function Node using a "C String Pointer" parameter as Azim suggested, and overwrite its contents in the DLL. One way to allocate the string is to use Initialize Array to create a u8 array of the desired size, and then use Byte Array To String to convert it to a string.</p> <p>Be sure that the string you pass in is large enough to hold the contents of your string, and make sure to pass the string length to the DLL so that it knows how large the buffer is. I believe that the default parameter is an empty string. Figuring out the right string length may require calling into the DLL twice, if your VI's first guess isn't large enough.</p></li> <li><p>Pass the string to the Call Library Function Node using a "String Handle" parameter, and use LabVIEW functions in your DLL to resize the string as necessary. This requires your DLL to be specifically designed to interface with LabVIEW and requires linking against a static library that is provided with LabVIEW.</p> <p>An example of this method ships with LabVIEW as <code>examples/dll/hostname/hostname.vi</code>.</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload