Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
6 ratings:
 2 out of 5     Rate this Document

Using a Call Library Function Node to Call a DLL Function that Returns a String that Includes Null Characters

Primary Software: LabVIEW Run-Time Engine
Primary Software Version: 7.1
Primary Software Fixed Version: 7.1
Secondary Software: N/A

Problem: My Call Library Function Node does not return the complete string when it calls a DLL function.

Solution: Your DLL function may be returning a string which contains null characters.
In order to return a string that includes null chararcters, the string has to be treated as an array of bytes. One way of accomplishing this is to perform the following steps:

1. Initialize an array using the Initialize Array function. Wire a numeric constant with representation set to U8 to the element input and set the dimension size to be at least the total number of characters in the string.

2. Set the initialized array as an input parameter to the Call Library Function Node.

3. Convert the output of the node from an array of bytes back to a string using the Byte Array to String function.

Attached below are two example vi's. Both vi's read the output of nationalinstruments.dll, which returns a 14 character string "Labview/0Rocks/0" where the /0 is a null character that exists between the two words and at the end of the string. The first example (InvalidDLLReadNullBytes.vi) tries to read the sting without initializing the data type to a byte array, and does so unsuccessfully. The second example (ValidDLLReadNullBytes.vi) follows the steps above and successfully returns the entire string from the dll.

Related Links:

Attachments:


nationalinstruments.dllInvalidDLLReadNullBytes.viValidDLLReadNullBytes.vi


Report Date: 06/14/2004
Last Updated: 08/30/2004
Document ID: 3AD7S2XR

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit