Determine the available Serial Port on a system

L

LongBow

Hello,

Is there a way, in .NET, to determine what are the avialable Serial
(Communications) Ports on a Windows OS and is there a way to determine
that port isn't being use other than attempting to opening the Serial
Port and catching the associated exception? Thanks

If there isn't a way to determine the Serial Port within .NET I would
be willing, I guess, to use a WinAPI is that was the only way.

Mark
 
Y

Your_Persona

The System.IO.Ports namespace contains classes for controlling serial
ports. The most important class, SerialPort, provides a framework for
synchronous and event-driven I/O, access to pin and break states, and
access to serial driver properties. It can be used to wrap a Stream
objects, allowing the serial port to be accessed by classes that use
streams.

http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport.aspx

Hope that covers your requirements.

Have a great one.

Austin
 
G

Guest

Besides noted there, I'd add that u can use WMI class "Win32_SerialPort" and
check the Availability property
See MSDN for more details

--
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
L

LordHog

Your_Persona said:
The System.IO.Ports namespace contains classes for controlling serial
ports. The most important class, SerialPort, provides a framework for
synchronous and event-driven I/O, access to pin and break states, and
access to serial driver properties. It can be used to wrap a Stream
objects, allowing the serial port to be accessed by classes that use
streams.

http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport.aspx

Hope that covers your requirements.

Have a great one.

Austin


Austin,

Thanks for the info and I am currently using the System.IO.Ports
class for the serial communications, but what I want is a way to
determine the available ports that are present on the current system.

The Serial Port namespace is pretty nice, though I don't like how the
data is buffered, and props goes to the intern at Microsoft that
initially created the class.

I will give the WMI a go as Michael indicated in his post. So from my
current understanding this is no native .NET way of determining the
enumerated list of available ports on a system. Hopefully Microsoft
might add that feature in the future.

Mark
 
J

JR

SerialPort.GetPortNames ();

JR

Austin,

Thanks for the info and I am currently using the System.IO.Ports
class for the serial communications, but what I want is a way to
determine the available ports that are present on the current system.

The Serial Port namespace is pretty nice, though I don't like how the
data is buffered, and props goes to the intern at Microsoft that
initially created the class.

I will give the WMI a go as Michael indicated in his post. So from my
current understanding this is no native .NET way of determining the
enumerated list of available ports on a system. Hopefully Microsoft
might add that feature in the future.

Mark
 
L

LordHog

JR,

Thanks A LOT! I didn't even see the static GetPortNames() from the
Serial Class. Thanks!!!!

Mark
 

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