LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to bundle a String-pointer into a cluster?

Hi

I have to pass a cluster into a DLL (called by reference). Theres is no
problem, it works.

But, one component in the cluster should be a pointer of a char-array
(String). How can I manage them?

Thanks Mareike
0 Kudos
Message 1 of 5
(2,641 Views)
Unfortunately, when you use the Adapt to Type input on a Call Library Node, you are at the mercy of LabVIEW's data types. In this case, LabVIEW will only pass a string and a LStrHandle (a handle to a pascal style string). Look at app note 154 for more on this. The workarounds would be to A)generate a string pointer in some other piece of external code and pass the pointer through LabVIEW as an int32, or create a DLL wrapper function to assemble the struct the way you need it before calling the actual function.
0 Kudos
Message 2 of 5
(2,640 Views)
You can use windows function:

lstrcpyn, from kernel32.dll

It takes two string pointers, and gives a string pointer back. Here's the
trick;

Wire the first input with a string buffer, at least the length of the input
string.
Wire the second with the desired string.

The routine will copy the desired string into the buffer, and return (in the
return value) a pointer to the copy.

Make a VI out of this, and make the vi reentrant....

Now you can get pointers to strings, without home made external code.

Regards,

Wiebe.




"Aaron Marks" wrote in message
news:506500000005000000F3600000-1012609683000@exchange.ni.com...
> Unfortunately, when you use the Adapt to Type input on a Call Library
> Node, you are at the mercy of LabVIEW's data types. In this
case,
> LabVIEW will only pass a string and a LStrHandle (a handle to a pascal
> style string). Look at app note 154 for more on this. The
> workarounds would be to A)generate a string pointer in some other
> piece of external code and pass the pointer through LabVIEW as an
> int32, or create a DLL wrapper function to assemble the struct the way
> you need it before calling the actual function.
0 Kudos
Message 3 of 5
(2,640 Views)
Yes, it works!

Thanks,
Mareike

"AIR" wrote in message news:a4vlv1$ipi$1@news1.xs4all.nl...
> You can use windows function:
>
> lstrcpyn, from kernel32.dll
>
> It takes two string pointers, and gives a string pointer back. Here's the
> trick;
>
> Wire the first input with a string buffer, at least the length of the
input
> string.
> Wire the second with the desired string.
>
> The routine will copy the desired string into the buffer, and return (in
the
> return value) a pointer to the copy.
>
> Make a VI out of this, and make the vi reentrant....
>
> Now you can get pointers to strings, without home made external code.
>
> Regards,
>
> Wiebe.
>
>
>
>
> "Aaron Marks" wrote in message
> news:506500000005000000F3600000-101260
9683000@exchange.ni.com...
> > Unfortunately, when you use the Adapt to Type input on a Call Library
> > Node, you are at the mercy of LabVIEW's data types. In this case,
> > LabVIEW will only pass a string and a LStrHandle (a handle to a pascal
> > style string). Look at app note 154 for more on this. The
> > workarounds would be to A)generate a string pointer in some other
> > piece of external code and pass the pointer through LabVIEW as an
> > int32, or create a DLL wrapper function to assemble the struct the way
> > you need it before calling the actual function.
>
>
>
0 Kudos
Message 4 of 5
(2,640 Views)
I also facing same problem but i could able to run this i have attached my code here pls give ur suggestion
Message Edited by jaffer on 05-08-2009 09:26 AM
0 Kudos
Message 5 of 5
(2,224 Views)