LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Returning CStrings.

Hi!

I have made a LabVIEW application that uses a DLL for saving and loading files. When I load a new file I want to display a string that is stored in the file in an String Control. What I tried was to pass the CString pointer to my DLL, copying the data to the string and then connect the the "Call library function" to a Local Variable of the String Control I want the text to be displayed in.
This causes a error message from NT indicating that I write in memory that Im not allowed to write in...

So my questions are:

1. How do I return a string from a DLL to LabVIEW?
2. How do I allocate/resize a string in LabVIEW?

TIA

/Thomas
0 Kudos
Message 1 of 5
(3,234 Views)
Hi Tomas,

This link should provide the answers for you. The examples provides different inputs and output to and from a dll.

http://zone.ni.com/devzone/explprog.nsf/webmain/F5F5257756C4D0F88625651B005C9A5E?opendocument&node=DZ52048_US

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 2 of 5
(3,234 Views)
Tobe;

Along with Ray's answer, check also the following example at NI Developer Zone:

Passing a Variety of Data Types from DLL to LabVIEW


You accomplish returning a string to LabVIEW in three steps:


1. First you resize the LV string to accomodate your C++ string using the function NumericArrayResize(). For example:


NumericArrayResize(uB, 1L,(UHandle *)&LV_string, c_string_size);


2. Then, update the length of the LV string. For example:


LStrLen(*LV_string) = c_string_size;


3. Finally, move the bytes from your C++ string to the LV string using the function MoveBlock(). For example:


MoveBlock(c_s
tring, LStrBuf(*LV_string), c_string_size);


Regards;
Enrique
www.vartortech.com
0 Kudos
Message 3 of 5
(3,234 Views)
Hi,

I can't load this example, I get some error about a DLL missing. And, this seams to only send doubles and return 32bit intergers? I want to return a string which is not as simple as returning an integer (anyway, thats my experience).

Thanks anyway,

/Thomas
0 Kudos
Message 4 of 5
(3,234 Views)
Hi,

sorry about that, Enrique got the right example.

Ray
Regards
Ray Farmer
0 Kudos
Message 5 of 5
(3,234 Views)