cancelar
Mostrando los resultados de 
Buscar en lugar de 
Quiere decir: 

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
Mensaje 1 de 5
3.922 Vistas
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
Mensaje 2 de 5
3.922 Vistas
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
Mensaje 3 de 5
3.922 Vistas
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
Mensaje 4 de 5
3.922 Vistas
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
Mensaje 5 de 5
3.922 Vistas