I have a system in which there are some devices with which it interacts via virtual COM ports. Over time, the COM port numbers change. I made a code that will look for new COM port numbers for these devices and remember them. It works great.
My problem is to determine the search range of the COM port number. I found in Microsoft KB that there is usually (by default) a limit of 256 COM ports on Windows NT. They also indicate that this is configurable and nothing prevents the system from having a completely different maximum COM port number.
I am wondering if there is a way to programmatically find out the range of COM port numbers. Obviously, if I allow the system to search only range 2, it will take a much shorter time than searching, say, range 2ยนโถ! But if the system running on my application is configured to support more than 2 COM ports, at some point the application will certainly crash again and again until the allocation of the COM port number returns to COM0 (or is it COM1?). I would like to avoid this if it does not require too much witchcraft.
I mainly work with Java, but any idea is welcome.
source share