By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,640 Members | 1,581 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,640 IT Pros & Developers. It's quick & easy.

Determine the available Serial Port on a system

P: n/a
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
Nov 16 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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/lib...erialport.aspx

Hope that covers your requirements.

Have a great one.

Austin

On Nov 16, 2:10 am, LongBow <p...@mud.poolwrote:
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
Nov 16 '06 #2

P: n/a
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


"LongBow" wrote:
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
Nov 16 '06 #3

P: n/a

Your_Persona wrote:
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/lib...erialport.aspx

Hope that covers your requirements.

Have a great one.

Austin

On Nov 16, 2:10 am, LongBow <p...@mud.poolwrote:
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

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

Nov 16 '06 #4

P: n/a
JR
SerialPort.GetPortNames ();

JR

<Lo*****@hotmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
>
Your_Persona wrote:
>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/lib...erialport.aspx

Hope that covers your requirements.

Have a great one.

Austin

On Nov 16, 2:10 am, LongBow <p...@mud.poolwrote:
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


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

Nov 16 '06 #5

P: n/a
JR,

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

Mark

JR wrote:
SerialPort.GetPortNames ();

JR

<Lo*****@hotmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...

Your_Persona wrote:
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/lib...erialport.aspx

Hope that covers your requirements.

Have a great one.

Austin

On Nov 16, 2:10 am, LongBow <p...@mud.poolwrote:
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

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
Nov 16 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.