08-15-2007 12:02 PM
08-15-2007 02:55 PM
08-15-2007 04:49 PM
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.
Cheers!
08-15-2007 10:52 PM
08-16-2007 01:29 AM - edited 08-16-2007 01:29 AM
Hi Paul,
First I'd get Guenter's suggestion working - it should work! (and would make the parameter-passing very simple.)
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.
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.
Cheers!
Message Edited by tbd on 08-16-2007 01:30 AM
08-16-2007 09:45 AM
08-16-2007 04:22 PM
@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.