03-03-2015 06:12 AM
Hello,
I've got a C-DLL from a hardware vendor and try to write a wrapper DLL to match the LabVIEW data types.
One of the vendor DLL functions is declared as:
MCHP_USB2530API_API HANDLE MchpUsbOpen ( UINT16 VendorID, UINT16 ProductID );
I've read somewhere that a HANDLE is nothing else but a UINT32 value, but Visual Studio declares it as a void *.
So how can I pass this HANDLE from my wrapper DLL to LabVIEW?Thanks.
03-03-2015 07:17 AM - edited 03-03-2015 07:18 AM
A C programmer is free to define datatypes to anything he likes, so it is hard to say with authority what your HANDLE datatype might be. In the Windows API a HANDLE is a pointer and your DLL is likely to also use that same datatype, but there are no guarantees without seeing the entire header file (and any dependency header files) for your DLL.
If it is the same than the Windows HANDLE then you should rather configure it as pointer sized (unsigned) integer in the LabVIEW Call Library Node configuration. It is indeed equivalent in size to an uint32_t on LabVIEW 32 Bit but an uInt64_t on LabVIEW 64 Bit. The pointer sized (unsigned) integer configuration takes automatically care about this difference.
10-06-2015 08:25 AM
Schuller,
It looks like we are working on the same thing. I am curious if you managed to get this working and if you would be willing to share. Sure would save me a lot of work and headache. You can email me direct at dale.potter@delphi.com
10-14-2015 04:07 AM
Yes, I managed to get this working.
In the Call Library Function I've declared the HANDLE as Type = Numeric, Data Type = Unsigned 32-bit Integer, Pass = Pointer to Value.
10-14-2015 04:59 AM
@schuller wrote:
Yes, I managed to get this working.
In the Call Library Function I've declared the HANDLE as Type = Numeric, Data Type = Unsigned 32-bit Integer, Pass = Pointer to Value.
I would recommend to use here instead:
Type = Numeric, Data Type = Pointer-sized Integer, Pass = Pointer to Value.
10-14-2015 08:31 AM
I ended up using the "Type = Numeric, Data Type = Pointer-sized Integer, Pass = Pointer to Value. " solution and it worked perfectly. Thanks for the reply.