Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Passing strings from C++ to labview cluster using DLL

204 views
Skip to first unread message

Richard Ashe

unread,
Jun 20, 2002, 11:45:08 AM6/20/02
to
I am using a Visual C++ front end to collect data which I wish to package
into a struct as input for a cluster within a labview DLL. The labview
string is of type LStrHandle which makes it difficult to copy the C++ string
into the labview string before calling the DLL function. Does anyone know a
way of doing this - some kind of strcpy/LStrPrintf function.

Thanks,
Richard.


Enrique

unread,
Jun 20, 2002, 3:37:11 PM6/20/02
to
Richard Ashe;

You accomplish this 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, cpp_string_size);

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

LStrLen(*LV_string) = cpp_string_size;


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

MoveBlock(cpp_string, LStrBuf(*LV_string), cpp_string_size);

If your C++ string is of the type CString, then you need to use the
function LPCTSTR() to obtain the pointer of the character string.

Regards;
Enrique

0 new messages