QString com_port;
HANDLE hComPort;
for (int i=1;i<=16;i++)
{
com_port.clear();
com_port.sprintf("COM%d",i);
//hComPort= CreateFile(com_port.utf16(), GENERIC_READ |GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
hComPort= CreateFile(com_port.utf16(), GENERIC_READ |GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
if (hComPort == INVALID_HANDLE_VALUE)
{
hComPort= 0;
}
else
{
m_ledBoardCOMPort->addItem(com_port);
m_irBoardCOMPort->addItem(com_port);
}
CloseHandle(hComPort);
}
I have writtern the code to find the acive COM port, But if the COM Port name is COM11, COM12 then it is unable to find. Only upto COM9 it is able to find.
Please help me that how to get evn if the COM Port is COM10 or COM11 also.
Bookmarks