Subj : Serial port query
To : Darin McBride
From : Vitus Jensen
Date : Wed Aug 09 2000 08:23 pm
Moin Darin!
06.08.2000, Darin McBride wrote a message to Vitus Jensen:
...
DM>>> Is there a way 1. to check the state of a port, 2. determine the
DM>>> application using it?
DM>>> By #1, I believe he means "determine if a comm port was in use".
DM>>> Any ideas whatsoever would be appreciated. I believe #1 can be done
DM>>> by an attempt to open the port as a file in "DENY_ALL" mode - if it
DM>>> fails, someone is using it. I don't believe #2 is possible. If I
DM>>> could be corrected, that would be great. :-)
VJ>> Get OS2UNDOC from hobbes and have a look at the DosQuerySysState API.
VJ>> It will return infos about all open files of a single or all
VJ>> processes. There are problems when using it at certain fixpak
VJ>> levels (older Warp 3 fixpaks).
DM> Of course! I forgot all about that. I already use that call for a
DM> number of things, so one more is no biggie. :-) Unfortunately, I
DM> can't figure out how to trace back from the file to the process(es).
Use the brute force method? See below.
DM> I've done some slight modifications to the sample programs given in
DM> the undoc INF file, and I get:
DM> I just can't tell how to get from one to the other.
...
There is this lees-than-optimal solution but why not use it:
get a list of all running processes via DosQuerySysState
for every process ID
get a list of all open files via DosQuerySysState
for every open file
check whether filename = COMx
if identical
dump process info (DosQuerySysState)
I don't think it would be too slow to be usable.
Bye,
Vitus
---
* Origin: Of all the things I've lost, I miss my mind the most. (2:2474/424.1)