LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DLL Function Call questions

param is a pointer to the LabVIEW native data structure that corresponds to the user event datatype. There are many considerations when dealing with LabVIEW datatypes in C and those can and do vary between the different LabVIEW platforms (yes even 32 bit Windows and 64 bit Windows are different here).

 

So the easiest way to get this right is by simply wiring that datatype to a Call Library Node where the according parameter has been configered as Adapt to Type. Then right click the CLN and select "Create C Code". The resulting C file has an empty function body for the function that the Call Library Node would want to call. And it has declarations of all the parameters and the according C types as LabVIEW uses them for native datatypes.

 

So you get the correct struct definition in that file and for structs also enclosed in includes for lv_prolog.h and lv_epilog.h. These two files take care about defining the aligment for the C compiler in the same way that LabVIEW is using and you will need to copy these includes together with the struct definition to your own source code file.

 

Just watch out from modifying your user event datatype after that. If the datatype of the user event doesn't match the datatype that your C code is passing to PostLVUserEvent(), very bad things might start to happen.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 11 of 13
(1,271 Views)

Ok, so I think I got the wrapper and event ready, but now I have an issue with the original DLL.

If I pass a NULL to the progress variable it will execute. But if I try to pass my cluster/structure to the Call Library Node, I get error 1097.

 

SendFileA(HANDLE handle, const char *src_filename, CustomProc progress);
typedef CUST_ERR (WINAPI *CustomProc)(unsigned long x, unsigned long y);

 

My cluster input to the Call Library Node is a cluster with two U32 numerics inside.

The node is set up as Adapt to Type.

Veni Vidi Duci
0 Kudos
Message 12 of 13
(1,264 Views)

@DB_IQ wrote:

Ok, so I think I got the wrapper and event ready, but now I have an issue with the original DLL.

If I pass a NULL to the progress variable it will execute. But if I try to pass my cluster/structure to the Call Library Node, I get error 1097.

 

SendFileA(HANDLE handle, const char *src_filename, CustomProc progress);
typedef CUST_ERR (WINAPI *CustomProc)(unsigned long x, unsigned long y);

 

My cluster input to the Call Library Node is a cluster with two U32 numerics inside.

The node is set up as Adapt to Type.


Please show your code. Again, the parameter that you need to be passing as the progress parameter is a pointer to a function - the memory address of the new callback function you created in your DLL. You probably need to add a function in your DLL that returns the address of the callback function.

 

You also need a function that you can call to store the reference to the LabVIEW Event in the DLL (for example, in a C global variable that's local to the DLL), so that when the callback function runs, it has access to that event reference.

0 Kudos
Message 13 of 13
(1,262 Views)