How to know a COM port is a modem

N

Nutshell

Hello everybody,
in my application I'd need to know if a com port is a modem or not (and
eventually its description and if it is a null modem).
I get the list of com ports available with:
string[] portList = System.IO.Ports.SerialPort.GetPortNames();
and then i set a port object like this:
System.IO.Ports.SerialPort sPort = new
System.IO.Ports.SerialPort(portList);
Is there some property of the serial port who tells me indirectly it is
a modem? As i said, I'd also need to get the modem description, and the
information about it being a null modem, a modem on a physical port or a
modem on a virtual usb com port (and i can't read the registry because
my application has to run also under Vista).
Any help would be appreciated, thank you.
Alberto
 
P

Peter Duniho

Hello everybody,
in my application I'd need to know if a com port is a modem or not (and
eventually its description and if it is a null modem).

Short of getting access to Windows' own list of known modems and
cross-referencing that with the list of COM ports, I don't see how you'd
be able to do this directly. That's sort of the point of the serial port,
is that anything could be connected to it. I wouldn't expect there to be
any sort of property associated with it that says "I have a modem
attached".

I don't know enough about Vista to understand why you can't get access to
the registry to get the information about modems from the Windows' data.
It seems to me that if a user can get access to the modems through the UI
somehow, then they must have read access to that portion of the registry
somehow. But I admit I have very little first-hand experience with Vista
so far. If you are sure that even when you make sure you don't try to
open the registry with write access, you still can't get at the data, I'll
take your word for it.

And assuming you can't look at the registry, AFAIK the only way to do it
is to try sending data to the modem and see what happens. For example,
send an appropriate "AT" command to get the modem status and see what
comes back (if anything). Of course, if there's something attached to the
serial port that's NOT a modem, that might not be the nicest thing to do.
:)

Pete
 
N

Nutshell

Peter Duniho ha scritto:
And assuming you can't look at the registry, AFAIK the only way to do it
is to try sending data to the modem and see what happens. For example,
send an appropriate "AT" command to get the modem status and see what
comes back (if anything). Of course, if there's something attached to
the serial port that's NOT a modem, that might not be the nicest thing
to do. :)

I can't try to open all available ports since they could be in use by
another processes, but I think I found another way to do it, if it works
i'll post it.
 
P

Peter Duniho

I can't try to open all available ports since they could be in use by
another processes,

Yup. As I alluded to, directly querying the ports is not necessarily the
best solution.
but I think I found another way to do it, if it works i'll post it.

Man, what a tease. Not even a little hint as to what you're trying? :)

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top