Author |
Topic: Discovering which COM ports are free? (Read 660 times) |
|
g3nrw
Junior Member
member is offline


Posts: 74
|
 |
Discovering which COM ports are free?
« Thread started on: Feb 18th, 2015, 7:04pm » |
|
Hello again. A variation on COM port questions I have asked before:
I have a program that needs to discover which COM ports are free. I have tried the simple way:
1. Attempt to open each port on the system.
2. If the open is successful, that port is available for use.
3. Immediately close the port.
This is fine, except the act of opening a port, however briefly, can cause other programs using the COM ports (over which I have no knowledge or control) to hiccup. I have a user with this problem right now.
There must be a way in BB4W to test for free COM ports without attempting to open them, but I can't see how. Any pointers?
-- Ian
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Discovering which COM ports are free?
« Reply #1 on: Feb 18th, 2015, 8:27pm » |
|
on Feb 18th, 2015, 7:04pm, g3nrw wrote:the act of opening a port, however briefly, can cause other programs using the COM ports (over which I have no knowledge or control) to hiccup. |
|
My guess is that the 'other program' isn't using legitimate Windows API calls to open the port, and that instead it's using some low-level direct port access using a driver such as INPOUT32.DLL. Windows may not even be aware the port is in use.
If that's the case, there's nothing you can do about it. The other program is at fault, not you. You will need to politely inform your user that he is using a program which breaks the rules of Windows. It will potentially be exposing security loopholes too.
As a workaround, could you perhaps provide a configuration option in your program allowing the user to specify ports that must not be scanned?
Windows should provide complete isolation between programs which open a serial port 'properly', and I have no reason to think it doesn't.
Richard.
|
« Last Edit: Feb 18th, 2015, 8:29pm by rtr2 » |
Logged
|
|
|
|
g3nrw
Junior Member
member is offline


Posts: 74
|
 |
Re: Discovering which COM ports are free?
« Reply #2 on: Feb 21st, 2015, 6:15pm » |
|
I was thinking exactly the same. The chances of getting someone else to modify their software is pretty remote, so I have given up in that direction.
For now, then, I will simplify the program by reading the Windows Registry to build a list of which serial ports exist on the system, and then present the list to the user to choose from.
Thanks for your help.
-- Ian
|
|
Logged
|
|
|
|
|