LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

complicated structure for DLL function

I need LV6 to pass and get back parameters to a DLL function whose prototype is:

int APIENTRY GetData(ACQDATA *Data)

ACQDATA has the following structure

typedef struct{
unsigned long huge *s0;
unsigned long far *region;
unsigned char far *comment0;
double far *cnt;
HANDLE hs0;
HANDLE hrg;
HANDLE hcm;
HANDLE hct;
}ACQDATA;
From the DLL documentation I could see that
- the function modifies its argument
- the (fixed) length of the second, third and fourth parameter is specified
No idea of the length of "s0". I've tried several LV clusters including a cluster with four pre-allocated arrays (buffers) and four scalars. But no luck so far.

If a C wrapper function is the only solution to pass the parameters correct
ly, can anyone show me an example. Can I use the Code Interface Node for that purpose though I only own the Base Package version of LV or shall I write another DLL function?
Please help asap
0 Kudos
Message 1 of 3
(2,890 Views)
When you say you've "had no luck," what is it that's happening when you do try this? I'm curious as to what behavior you are seeing. Also, what is the HANDLE data type? Is that one you created or is it associated with the SQL handle data types? Let me know when you get a chance and we'll look into this some more.
J.R. Allen
0 Kudos
Message 2 of 3
(2,890 Views)
Unfortunately I am new to C programming, but I'll try to give you the complete picture of what happens.
There's no definition for HANDLE in the DLL documentation but windows.h is included, so I guess the following
#define HANDLE void * //32bit?

In my LV routine I tried U32 variables for the HANDLE typed parameters.
In one of attempt LV passes to the function a cluster (I make no mistake with the order!) with four arrays and four U32, all of them preset to some value. Well.. these values (all)are not changed when the function returns. The return value of the function says no error, anyway.
I tried other clusters: with and without arrays, with all (or part) scalars and all (or part) strings. No way either.
Sometimes LV itself crashes, sometimes I get
the original values I imposed before the call.

I suspect the LV cluster structure makes me miss the right level of indirection for the first 4 variables in the structure (called *s0, *region, *comment and *cnt): when either I pass arrays or scalars as components of the cluster.

Hope this helps you to help me

Cheers
Piero
0 Kudos
Message 3 of 3
(2,890 Views)