LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cstring pointer dll

Hi,

This is a really simple question.
I make my own dll and I would like to pass a Cstring from Labview to this dll. The dll is in C++. When I pass the string in the Call library finction node, I can pass a Cstring pointer.

How my prototype in C++ should be? void function(string *thestring); or void function(string thestring);? (because it's a Cstring POINTER)

thanks
0 Kudos
Message 1 of 5
(3,157 Views)
hi poly,

just build up the parameterlist of an empty CallLibrary-Node and right-click "Create C-File" on the node (you don't need to specify a dll when building the parameterlist). LV then creates a C-Code stub for you.

greetings
chris
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 2 of 5
(3,157 Views)
Hi,

I'm not really sure I understand what you mean. I will try it.
However, the dll is already done and I can change it so I think I would be less complicated if I just change the input parameter in my prototype from "string thestring" to "string *thestring".
I'm just a little mixed up in the definition of a "Cstring pointer".

Thx
0 Kudos
Message 3 of 5
(3,157 Views)
You can try doing void function(std::string thestring), that might work because of copy constructor on string.

However i usually have void function(TCHAR* thestring) and that does work.

A Rafiq
0 Kudos
Message 4 of 5
(3,157 Views)
Hi,

In terms of LabVIEW a C string pointer is just an array of characters terminated by a NULL character. When LabVIEW calls the DLL, it will pass a pointer to an array of characters where a 0 defined the end of the string.

The function prototype can be something like

void MyFunction(char *myString);

I know MFC offers the CString class to make string management easier. You can go back an forward between a CString tyoe and a char[]. You can assign a char[] to a CString with the "=" operator and uses the LPCTSTR operator to convert a CString to char[].

I hope this helps

Regards,

Juan Carlos
N.I.
0 Kudos
Message 5 of 5
(3,157 Views)