Showing results for 
Search instead for 
Did you mean: 

how to use Call library function node for a function in dll with VOID data type

Go to solution

Hi All,

I would like to ask for your kind help,

I am facing an issue with the call library node.

I have a C++ function(stdcall), which has void as data type

error code XXXX(hwnd, lID, getValue, *void data1, *void data2)

the data1 and data2 types are always changing depending upoin the value of "getValue".

Primarily i can use call library node multiple times and adapt each node according to the data types of data1 and data2, and extract the values and use in the code. Here is no issue. Real question is:



My question:

How can i just use one time call library node and make a case depending upon the "getvalue", which will control the data type of data1 and data2. Here i really looking for solutions.


My trials:

i used varaints as input to the call libray node for data1 and data2, and selected Parameters in call libraby node as " Adapt to type". here labview just crashed.


i really appreciate your feedbackand suggestions.






0 Kudos
Message 1 of 5
Accepted by topic author KVO

You need to allocate enough space for data1 and data2, then pass a pointer to that space. An easy way to do this is the initialize array function. Set the type to U8 and the size to the number of bytes needed. Pass that array to the function as an array data pointer.


After the function call returns, you need to extract the data from the array. You could do this manually, but a simple approach is to use byte array to string. Then, in a case structure, use Unflatten From String to convert the string to the correct data type. This approach also converts endianness which will probably be necessary; make sure you set all the inputs to unflatten properly.

Message 2 of 5

A variant is a very specific LabVIEW datatype (really a C++ type object internally) and trying to pass that to a function, which excepts a flat memory pointer there, for sure will crash very quickly.


As to endianess, yes Unflatten will be able to adjust for endianess, which in this case however is most likely exectly NOT what you want. So make sure that the you select native type for the endianess input on Unflatten from String. LabVIEW internally works with whatever is the native endianess, as will most likely your C++ DLL. The platform independent big endian format does only come into play when you receive data streams over some streaming interface like a network connection. Here it is desirable to use an endian format that is independent from the actual platform that generates and consumes the data stream. LabVIEWs default endianes is big endian here.


But as long as you pass data directly to native components like DLLs there is no difference in endianess between what LabVIEW uses and what those components use.

Rolf Kalbermatter
My Blog
Message 3 of 5

Hi Nathand, many thanks for your response, I tried the exact way you proposed and it is working. this definately help me in makinf a generic driver.

I took care of endianness, and i could extract the data.


Thanks Kutbuddin

0 Kudos
Message 4 of 5

Hi Rolf,

Thank you very much for your reply, it exactly fits, for the concept mentioned using unflatten string.I took care of endianness as well.

Many thanks again.



0 Kudos
Message 5 of 5