Hi, I am fairly new in C/C++ programming.
I want to scan available com ports 1-99.
This ugly method works, anyone having a
better propose?
CreateFile(pcCommPort, etc...
does not accept that pcCommPort is a string.
I am using dev-cpp
Code:char* pcCommPort; char portnbr; for (portnbr = 1; portnbr <=99; portnbr++) { // 1..7 if (portnbr == 8) { pcCommPort = "\\\\.\\COM8"; } if (portnbr == 9) { pcCommPort = "\\\\.\\COM9"; } if (portnbr == 10) { pcCommPort = "\\\\.\\COM10"; } if (portnbr == 11) { pcCommPort = "\\\\.\\COM11"; } // 12..99 hComm = CreateFile(pcCommPort, GENERIC_READ | GENERIC_WRITE, 0, // comm devices must be opened w/exclusive-access NULL, // no security attributes OPEN_EXISTING, // comm devices must use OPEN_EXISTING 0, // non overlapped I/O NULL // hTemplate must be NULL for comm devices );



LinkBack URL
About LinkBacks


