LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

get const char ** from DLL

Hi,

 

How to receive a const char ** from DLL. I am calling a function in a DLL whose definition is like this:

int functiona(int a, int b, const char ** d)

 

I tried setting Type: string, constant: check, string type: C String pointer, but it returns empty string. 

 

Does anyone know what's the correct procedure to get a constant string pointer from the DLL?

 

Thanks!

 

 

0 Kudos
Message 1 of 3
(3,259 Views)

In some cases where the memory is dynamically allocated, it's safer to dereference the pointer. Get an int instead of a string and dereference the pointer !

This might help : https://decibel.ni.com/content/docs/DOC-9091

Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.

0 Kudos
Message 2 of 3
(3,232 Views)

Basically this means that the function returns a pointer to a const string, most likely a string literal somewhere declared in the code. As such it is almost certain that it not only doesn't need to be deallocated but would cause undefined behaviour (what in C anything can mean from no apparent error, to strange runtime effects or a full crash).

 

The Call Library node parameter needs to be configured as pointer sized integer passed by pointer and you need to either use MoveBlock() call or GetValueByPointer, both having been explained many times on this forum in many posts (and the search function with one of these search words will return you just about all of them).

 

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 3
(3,216 Views)