I want to use LabVIEW's Call Library Function Node to access a DLL function, and have this function return a string to displayed on my VI. How would I go about doing this? I am quite happy returning numbers from my DLL, but am really struggling to find any examples of how to return a string.
I assume from your question that you already have a DLL that can return numbers to Labview. To return a string from the DLL, I have created a DLL with the following C++ function
void returnString(char myString[])
{
const char *aString = "test string";
memcpy(myString, aString, 12);
}
In Labview I then use the Call Library Function Node and configure it as follows
Library Name or Path: c:\path\to\my\custom.dll Function Name: returnString Calling Convention: C Parameters: Parameter: return type type: void Parameter: arg1 type: String string format: C String Pointer Function prototype: void returnString(CStr arg1);
After connect the arg1 output in the block diagram to a string indicator and run. The string "test string" should appear in the front panel.
I tried to have the returnString function be of type CStr as in
CStr returnString()
{ ...
}
but I got build errors when compiling the DLL project.
UpdateThanks to @bk1e comment don't forget to pre-allocate space in Labview for the string.