LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Call Library Node; enum structure

I suspect that I already know the answer to this.  But is it possible to pass in the following defined structure to the call library node from labview:

struct HStradisDecoder {
    unsigned long hHandle;
};
typedef struct HStradisDecoder* STRADISDECODER;


Thoughts and Ideas?
Using LabVIEW 8.0+

Paul
0 Kudos
Message 1 of 7
(3,427 Views)
Hi Paul,
in this special case the struct only contains one element of the data type unsigned.
If the DLL expects the struct by pointer you can pass from LabVIEW a pointer to a U32.
Regards, Guenter
Message 2 of 7
(3,410 Views)

Hi Paul,

In case you're interested, it's possible - even commonplace, when using the "Windows API" from LabVIEW - to represent and pass C-structures as LabVIEW arrays.  The DLL gets an "Array Data pointer" but assumes it's a "structure" pointer.  Constructing an array-representation of a stru of multiple elements and/or mixed-types can open the door to byte-padding problems.  I've never passed "really complex" strus and, in my expereince, byte-padding problems rare. Smiley Happy

Cheers!

 

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Message 3 of 7
(3,396 Views)
I am interested.  I tried passing a pointer to the U32 handle.  That did not work.  I tried a few other things.  As for the array?  I am not sure what you mean, simply convert the U32 as what?  a 4 byte array?  the dll in question has 650+functions.  I really do not want to wrap it. 

Paul
0 Kudos
Message 4 of 7
(3,382 Views)

Hi Paul,

First I'd get Guenter's suggestion working - it should work! (and would make the parameter-passing very simple.) Smiley Happy

Without knowing anything about the larger application it's difficult to guess why it didn't work.  Is the hHandle the correct value?  Does the "endian-ness" of hHandle change from caller (LabVIEW) to callee (DLL)?  - it might be necessary to reverse the byte-order of the U32/hHandle.Smiley Surprised

Attached is an example of a VI that calls a WinAPI (User32.dll) function.  The last two parameters to the DLL are non-trivial structures - passed and unpacked as arrays!

I stuffed the diagram with lots of prototypes, descriptions and links from MSDN - enjoy. Smiley Wink

Cheers!

 

Message Edited by tbd on 08-16-2007 01:30 AM

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Message 5 of 7
(3,372 Views)
If I was not frustrated this would have been funny.  The whole problem was that I was initializing the pointer with the DLL in the SDK directory and trying to call functions on the hardware using the DLL in the System32 directory. 
I appreciate the assistance, and the launcher.vi.  That information will come in handy with some of the more complex structures that I need to build for this hardware.

Paul
Message 6 of 7
(3,358 Views)
Enjoyed this - in a "happy-it-wasn't-me-this-time" sort of way! Smiley Very Happy 

@Stradis wrote:
If I was not frustrated this would have been funny.  The whole problem was that I was initializing the pointer with the DLL in the SDK directory and trying to call functions on the hardware using the DLL in the System32 directory. 



Cheers!
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 7 of 7
(3,334 Views)