LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DLL call with HANDLE type

Hello.
 
I have a 3rd party dll that is used to communicate to a device via serial port.  Each of the dll functions require a HANDLE type parameter which I gather is the handle for the serial port session.  How can I configure the call function to accommodate this data type?
 
Here's a sample function prototype:
 
int DkOpenSerial(int PortNumber, HANDLE& handle, int baud)
 
And here's a typical call to this function in C++:
 
int result;
int baud = 9600;
int PortNumber = 1;
HANDLE handle;
 
result = DkOpenSerial(PortNumber, handle, baud);
if(result != DK_SUCCESS)
{
   //Error handling here
}
else
   //No error - continue.
 
Any help or suggestions???
 
Thanks in advance!
0 Kudos
Message 1 of 5
(3,917 Views)
Try this explaination. Its a U32.
Message 2 of 5
(3,906 Views)

Thanks Odd_Modem!  That does help clear things up a bit. 

From what I gather from this article, the handle is either generated by Windows or assigned by the user.  I tried to assign a U32 to the handle, but it didn't work out too well for me.  Is there a way in LabVIEW to allow Windows to assign the handle for that instance and then read that value to a variable to use elsewhere?  

0 Kudos
Message 3 of 5
(3,897 Views)
The C prototype says handle & so that means the address of a handle. When you use the handle you have to pass in the address of a handle. You get the handle from a DLL function call and the return type is pointer to U32, a pointer to a handle *handle or pointer to U32. All the calls that use the handle are just U32 passed by value, which is the address of the handle. If your DLLs are not arrainged that way you might need a wrapper, or someone might know a different way.
0 Kudos
Message 4 of 5
(3,891 Views)

For anyone who comes across this thread:

 

Since LabVIEW 2009, the Call Library Node has a new numeric datatype called Pointer sized (unsigned) Integer. The HANDLE being declared as pointer to void should therefore be configured as such now instead of an (u)int32, otherwise you will run into problems if the DLL is ever going to be 64-bit and you move to LabVIEW 64-bit to call it.

 

The control on the frontpanel to pass in and out such a parameter should be a 64-bit (unsigned) Integer, LabVIEW will take care to use the relevant 32-bits on 32-bit platforms. 

Rolf Kalbermatter
My Blog
Message 5 of 5
(2,713 Views)