I want to get the list of com and parallel ports in the machine, is there a
way to do it in the .Net Framework.

Re: How can i get the list of Com ports in machine. by Christopher

Christopher
Tue Feb 24 12:38:54 CST 2004

The current version does not support COM ports from managed code.
If you know the Win32 API calls that are required, you can call these from
.NET using Platform Invoke.


Chris


"Umut Tezduyar" <utezduyar@onmap.com.tr> wrote in message
news:#X$Dl7h#DHA.3488@tk2msftngp13.phx.gbl...
> I want to get the list of com and parallel ports in the machine, is there
a
> way to do it in the .Net Framework.
>
>



Re: How can i get the list of Com ports in machine. by Dick

Dick
Tue Feb 24 13:12:49 CST 2004

Hi,

The only way that I know is to P/Invoke (Platform Invoke) the Windows32
EnumPorts APIs. There isn't anything in the .NET Framework that provides
this information.

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.



Re: How can i get the list of Com ports in machine. by Mike

Mike
Tue Feb 24 14:53:01 CST 2004

This might help:

Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_POTSModem")
moReturn = moSearch.Get

For Each mo In moReturn
Debug.WriteLine(mo("Name") & " is attached to " &
mo("AttachedTo"))
Next



"Dick Grier" <dick_grierNOSPAM@msn.com> wrote in message
news:%23ykqpow%23DHA.2336@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> The only way that I know is to P/Invoke (Platform Invoke) the Windows32
> EnumPorts APIs. There isn't anything in the .NET Framework that provides
> this information.
>
> Dick
>
> --
> Richard Grier (Microsoft Visual Basic MVP)
>
> See www.hardandsoftware.net for contact information.
>
> Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
> Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
>
>



Re: How can i get the list of Com ports in machine. by james

james
Tue Feb 24 16:13:38 CST 2004

I tried this and cannot get VB.NET 2003 to work with this. I even find
references to :
Imports System.Management
in the Help files. But, still adding that outside the module in a Console
app. it still generates an error.
(sorry to jump in here but, this looked like an easy way to find the
commports.)
So, I am curious how you are getting this to work.
james

"Mike Hildner" <mhildner@afweb.com> wrote in message
news:u6J9qgx#DHA.3272@TK2MSFTNGP09.phx.gbl...
> This might help:
>
> Dim moReturn As Management.ManagementObjectCollection
> Dim moSearch As Management.ManagementObjectSearcher
> Dim mo As Management.ManagementObject
>
> moSearch = New Management.ManagementObjectSearcher("Select * from
> Win32_POTSModem")
> moReturn = moSearch.Get
>
> For Each mo In moReturn
> Debug.WriteLine(mo("Name") & " is attached to " &
> mo("AttachedTo"))
> Next
>
>
>
> "Dick Grier" <dick_grierNOSPAM@msn.com> wrote in message
> news:%23ykqpow%23DHA.2336@TK2MSFTNGP11.phx.gbl...
> > Hi,
> >
> > The only way that I know is to P/Invoke (Platform Invoke) the Windows32
> > EnumPorts APIs. There isn't anything in the .NET Framework that
provides
> > this information.
> >
> > Dick
> >
> > --
> > Richard Grier (Microsoft Visual Basic MVP)
> >
> > See www.hardandsoftware.net for contact information.
> >
> > Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
> > Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
> >
> >
>
>



RE: How can i get the list of Com ports in machine. by anonymous

anonymous
Tue Feb 24 16:16:07 CST 2004

I think that Dart makes a nice .Net comm control if you don't feel like messing around with p/invoke.

Re: How can i get the list of Com ports in machine. by Mike

Mike
Tue Feb 24 19:21:27 CST 2004

Umm, whoops, I forgot to give credit where credit is due. Sorry. That code
was actually posted by a Mr. Ken Tucker on another Microsoft group (can't
remember where). Apologies, Ken. There's a glitch or two depending on the
OS, apparently.

If you want the full story (AFAIK), check out
http://vbforums.com/showthread.php?s=&threadid=273454

Thanks Ken,
Mike


"Mike Hildner" <mhildner@afweb.com> wrote in message
news:OcxWhVy%23DHA.808@TK2MSFTNGP12.phx.gbl...
> Here's a quickie console VB.NET project that enumerates the com ports. Not
> sure if I can attach, so if I can't, give me an email.
>
> Mike
>
> "james" <jjames700ReMoVeMe at earthlink dot net> wrote in message
> news:u4SJ7Ny%23DHA.3184@TK2MSFTNGP09.phx.gbl...
> > I tried this and cannot get VB.NET 2003 to work with this. I even find
> > references to :
> > Imports System.Management
> > in the Help files. But, still adding that outside the module in a
Console
> > app. it still generates an error.
> > (sorry to jump in here but, this looked like an easy way to find the
> > commports.)
> > So, I am curious how you are getting this to work.
> > james
> >
> > "Mike Hildner" <mhildner@afweb.com> wrote in message
> > news:u6J9qgx#DHA.3272@TK2MSFTNGP09.phx.gbl...
> > > This might help:
> > >
> > > Dim moReturn As Management.ManagementObjectCollection
> > > Dim moSearch As Management.ManagementObjectSearcher
> > > Dim mo As Management.ManagementObject
> > >
> > > moSearch = New Management.ManagementObjectSearcher("Select *
> from
> > > Win32_POTSModem")
> > > moReturn = moSearch.Get
> > >
> > > For Each mo In moReturn
> > > Debug.WriteLine(mo("Name") & " is attached to " &
> > > mo("AttachedTo"))
> > > Next
> > >
> > >
> > >
> > > "Dick Grier" <dick_grierNOSPAM@msn.com> wrote in message
> > > news:%23ykqpow%23DHA.2336@TK2MSFTNGP11.phx.gbl...
> > > > Hi,
> > > >
> > > > The only way that I know is to P/Invoke (Platform Invoke) the
> Windows32
> > > > EnumPorts APIs. There isn't anything in the .NET Framework that
> > provides
> > > > this information.
> > > >
> > > > Dick
> > > >
> > > > --
> > > > Richard Grier (Microsoft Visual Basic MVP)
> > > >
> > > > See www.hardandsoftware.net for contact information.
> > > >
> > > > Author of Visual Basic Programmer's Guide to Serial Communications,
> 3rd
> > > > Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
> > > >
> > > >
> > >
> > >
> >
> >
>
>
>



Re: How can i get the list of Com ports in machine. by james

james
Tue Feb 24 21:52:56 CST 2004

Got it. Thanks. I will give it a try.
james

"Mike Hildner" <mhildner@afweb.com> wrote in message
news:eI1as2z#DHA.1796@TK2MSFTNGP12.phx.gbl...
> Umm, whoops, I forgot to give credit where credit is due. Sorry. That code
> was actually posted by a Mr. Ken Tucker on another Microsoft group (can't
> remember where). Apologies, Ken. There's a glitch or two depending on the
> OS, apparently.
>
> If you want the full story (AFAIK), check out
> http://vbforums.com/showthread.php?s=&threadid=273454
>
> Thanks Ken,
> Mike
>
>
> "Mike Hildner" <mhildner@afweb.com> wrote in message
> news:OcxWhVy%23DHA.808@TK2MSFTNGP12.phx.gbl...
> > Here's a quickie console VB.NET project that enumerates the com ports.
Not
> > sure if I can attach, so if I can't, give me an email.
> >
> > Mike
> >
> > "james" <jjames700ReMoVeMe at earthlink dot net> wrote in message
> > news:u4SJ7Ny%23DHA.3184@TK2MSFTNGP09.phx.gbl...
> > > I tried this and cannot get VB.NET 2003 to work with this. I even find
> > > references to :
> > > Imports System.Management
> > > in the Help files. But, still adding that outside the module in a
> Console
> > > app. it still generates an error.
> > > (sorry to jump in here but, this looked like an easy way to find the
> > > commports.)
> > > So, I am curious how you are getting this to work.
> > > james
> > >
> > > "Mike Hildner" <mhildner@afweb.com> wrote in message
> > > news:u6J9qgx#DHA.3272@TK2MSFTNGP09.phx.gbl...
> > > > This might help:
> > > >
> > > > Dim moReturn As Management.ManagementObjectCollection
> > > > Dim moSearch As Management.ManagementObjectSearcher
> > > > Dim mo As Management.ManagementObject
> > > >
> > > > moSearch = New Management.ManagementObjectSearcher("Select *
> > from
> > > > Win32_POTSModem")
> > > > moReturn = moSearch.Get
> > > >
> > > > For Each mo In moReturn
> > > > Debug.WriteLine(mo("Name") & " is attached to " &
> > > > mo("AttachedTo"))
> > > > Next
> > > >
> > > >
> > > >
> > > > "Dick Grier" <dick_grierNOSPAM@msn.com> wrote in message
> > > > news:%23ykqpow%23DHA.2336@TK2MSFTNGP11.phx.gbl...
> > > > > Hi,
> > > > >
> > > > > The only way that I know is to P/Invoke (Platform Invoke) the
> > Windows32
> > > > > EnumPorts APIs. There isn't anything in the .NET Framework that
> > > provides
> > > > > this information.
> > > > >
> > > > > Dick
> > > > >
> > > > > --
> > > > > Richard Grier (Microsoft Visual Basic MVP)
> > > > >
> > > > > See www.hardandsoftware.net for contact information.
> > > > >
> > > > > Author of Visual Basic Programmer's Guide to Serial
Communications,
> > 3rd
> > > > > Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
> >
>
>