More then 16 serial Ports
Hi,
I've more then 16 serial Ports in my PC (COM1+2 and COM5 to COM20). I work with MSVC++ 6.0 under WIN2000. With MSCOMM I cant see the ports 17 to 20. If I use CSerial I cant see Ports higher 9. What's wrong?
Here a little CODE with CSerial:
CString text;
CEdit* pEdit = (CEdit*) GetDlgItem(IDC_EDIT1);
CSerial Serial;
for (int i=1;i<25;i++)
{
if (Serial.Open( i, 9600))
text.Format("Der COM-Port: %i ist vorhanden", i);
else
text.Format("Der COM-Port: %i ist NICHT vorhanden", i);
pEdit->SetWindowText(text);
pEdit->RedrawWindow(NULL,NULL,RDW_UPDATENOW);
Sleep(500);
Serial.Close();
}
Who can help me?
Greetings Walter
bug in the class is fixed here...
Quite simply you need to change the code in CSerial::Open, to
if (nPort < 10)
wsprintf( szPort, "COM%d", nPort );
else
wsprintf( szPort, "\\\\.\\COM%d", nPort );
That should be self-explanatory from my sample code, which accepts the string "COM1" etc and "fixes" it.
The cool code with overlapped I/O is all very fancy, and if U read all of the overlapped I/O references this work-around is also documented there. It is called a UNC filename thingy?
Enjoy:)