‎11-27-2018 07:53 AM
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?
Solved! Go to Solution.
‎11-27-2018 02:41 PM - edited ‎11-27-2018 02:42 PM
@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.
‎11-28-2018 12:45 AM
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?
‎11-28-2018 01:46 AM - edited ‎11-28-2018 01:49 AM
@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.