From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

void *module argument in Call Library Function Node

Hi guys,

 

I build function from dll file. When i call a function which has void *module arg. I don't know how to set it in Labview. I hope everybody help me slove it. Thanks so much ^^!

I cann't attach dll and pdf file to this post.

0 Kudos
Message 1 of 6
(2,593 Views)

"Adapt to source" as data type ==> Void*

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 6
(2,573 Views)

Thank Yamaeda, I got it!

0 Kudos
Message 3 of 6
(2,537 Views)

@Yamaeda wrote:

"Adapt to source" as data type ==> Void*

/Y


This might be not the right solution in every case. void* as function parameter type (or function return value) can really mean three very different things. It can stand indeed for the case of a variable type that can change at runtime, based on other parameters of the function. Sort of a poor mans variant implementation for standard C.

 

The other and much more frequently occuring case is simply a pointer to some memory buffer. This could be a dynamically allocated memory buffer that the function returns and the caller has to use in some way. It can be directly a byte buffer where certain information is located at a certain offset that is well known or it is an opaque databuffer that holds information to an "object" that the caller is only supposed to access through API functions who know how to deal with the opaque "handle".

 

In both cases, the data pointer to a memory buffer, as well as the opaque handle, this datatype should be configured in the Call Library Node to be a pointer sized integer. If that pointer is a handle to an opaque object that is only accessed through other API functions you are done. If it is a pointer to a memory buffer that you have to dereference direcltly everything gets more dirty and you have to start to resort into tricks like calling the LabVIEW manager function MoveBlock() in the right way to get at the information in that buffer.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 6
(2,524 Views)

Good points Rolf (as always), a collegue recently had that problem, when a DLL call used void* and when we used the Adapt we didn't get it to work. By looking at the source we noticed that it used the real datatype in the function (U8 .. U32) so it worked alot better when simply feeding it one of those.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 6
(2,518 Views)

Well, Adapt to Type has a very specific way to deal with skalars. All skalars wired to an Adapt to Type terminal are always passed by reference. A Cluster is passed as pointer to the structure. The only datatypes where you have a little configuration possibility with Adapt to Type are LabVIEW handles (Arrays and Strings). Here the extra configuration option "Pass LabVIEW Handles as Handle" or "Pass LabVIEW Handles as Pointer to the Handle" will make an extra difference.

 

So if you have an "int *name" parameter you can either configure the parameter as "Adapt to Type" and wire an int32 to it or explicitedly as 32 Bit Integer passed as Pointer. If the parameter is "int name" the only option is to configure it explicitedly as 32 Bit Integer passed by Value.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 6
(2,510 Views)