QSerialPort handle on Windows

Hi. I've a problem trying to use QSerialPort's handle() method under Windows OS.

I'd like to open a QSerialPort and then grab its handle for performing some operations on the port using the native Windows API (I need to do that because I have to obey some requests from a third-party library).

Unfortunately, when I try to write some data on the Windows HANDLE returned by QSerialPort's handle() method then I have no effects: no data are being actually written on the port.

Under Linux everything is fine, instead: writing data on the QSerialPort's handle() using the native API succeeds.

I don't sure that it is correct to do I/O (ReadFile/WriteFile) to QSerialPort using handle(). In this case you do not need then QSerialPort at all!!!

QSerialPort opens device in overlapped mode, so, maybe it is reason, or you do ReadFile/WriteFile wrong.

QSerialPort "listen" any I/O events on HANDLE with IOCP and process it automatically, so, maybe it is reason.

Maybe something else.

QSerialPort::handle() it is possible to use to change any other features with DeviceIoControl (e.g. timeouts, speed and so on), but I don't think, that ReadFile/WriteFile is possible... Please use QSerialPort::handle() on your own risk. :)

The overlapped mode is the problem. If you only have a handle then ReadFile / WriteFile will fail if you don't include the overlapped structure in the call. It was opened with the OVERLAPPED flag so this parameter cannot be NULL.