LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass a HANDLE from a DLL to LabVIEW?

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.

0 Kudos
Message 1 of 6
(6,148 Views)

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. 

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 6
(6,132 Views)

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

 

0 Kudos
Message 3 of 6
(5,919 Views)

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.

0 Kudos
Message 4 of 6
(5,864 Views)

@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.

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 6
(5,849 Views)

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.

0 Kudos
Message 6 of 6
(5,823 Views)