LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to call dll function with the double asterix parameter

Solved!
Go to solution

I have a dll with header file. 

Function definition that I want to call is in header file and it looks like this:

 

 

DLL_EXPORT unsigned long CON_OpenInterface(
void ** ppHandle,
unsigned long interface,
const char * cmd,
const char * response, char * pResponse, unsigned long maxSize
);

I have parameterized call library function node as:

ppHandle: Numeric, Unsigned 32-bit Integer, Pointer to Value

interface: Numeric, Unsigned 32-bit Integer, Value

cmd: String, C String Pointer, <None>

response: String, C String Pointer, <None>

pResponse: String, C String Pointer, <None>

maxSize: Numeric, Unsigned 32-bit Integer, Value

 

But the function does not work. What am I doing wrong?

 

0 Kudos
Message 1 of 4
(977 Views)

@Skoda3 wrote:

I have a dll with header file. 

Function definition that I want to call is in header file and it looks like this:

 

 

DLL_EXPORT unsigned long CON_OpenInterface(
void ** ppHandle,
unsigned long interface,
const char * cmd,
const char * response, char * pResponse, unsigned long maxSize
);

I have parameterized call library function node as:

return value: Unsigned 32-bit Integer

ppHandle: Numeric, Unsigned pointer sized Integer, Pointer to Value

interface: Numeric, Unsigned 32-bit Integer, Value

cmd: String, C String Pointer, <None>

response: String, C String Pointer, <None>

pResponse: String, C String Pointer, Minimum size: maxSize

maxSize: Numeric, Unsigned 32-bit Integer, Value

 

But the function does not work. What am I doing wrong? 


And then pass some useful number to maxSize that specifies to the function how long the buffer is that pResponse has allocated for the function to write into.

Rolf Kalbermatter
Averna BV
0 Kudos
Message 2 of 4
(953 Views)

Can I please ask you for some additional information : Why void ** ppHandle should be of a Data Type: Unsigned Pointer-sized Integer? And if I would have only one asterisk like this: void * pHandle should I also use Unsigned Pointer-sized Integer for data type?

0 Kudos
Message 3 of 4
(943 Views)
Solution
Accepted by topic author Skoda3

@Skoda3 wrote:

Can I please ask you for some additional information : Why void ** ppHandle should be of a Data Type: Unsigned Pointer-sized Integer? And if I would have only one asterisk like this: void * pHandle should I also use Unsigned Pointer-sized Integer for data type?


Basically because the asterix indicates that it IS a pointer. And pointers have different sizes depending if the application is 32 bit or 64 bit. A double asterix simply means that it is a pointer sized integer passed by reference (in other words "Pass: Pointer to value").

As long as you work in LabVIEW 32 bit your configuration works too, but why limit it to only work in LabVIEW 32 bit? Sooner or later everyone will only work in 64 bit.

 

And yes if it is only void *pHandle it would still be a pointer sized integer but this time Pass: by Value.

 

The real problem you had is the second misconfiguration. You have to always make sure that any output buffer is preallocated. That is mandatory for C function calls, unlike what you are used in LabVIEW where a LabVIEW node automatically adjusts array and string buffers to the necessary size.

Rolf Kalbermatter
Averna BV
0 Kudos
Message 4 of 4
(937 Views)