C++ (Qt) hComm = CreateFile( "COM1:", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); if (INVALID_HANDLE_VALUE == hComm) { qDebug("Unable to open the port"); return false; } GetCommState(hComm, &PortDCB); PortDCB.BaudRate = m_baudRate; if (FALSE == SetCommState(hComm, &PortDCB)) { qDebug("Unable to configure the serial port"); return false; }
C++ (Qt) DWORD lpNumberOfBytesRead; char* lpBuffer = new char[m_readBufferLength]; ReadFile( hComm, lpBuffer, m_readBufferLength, &lpNumberOfBytesRead, NULL);