471,316 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 software developers and data experts.

Getting serial port information over WMI

Hello,

how to get information about all serial ports in the PC?

I use the following code, but i got only the data of the FIRST serial port.
All other serial port information are not available with this code sample:

ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select *
from WIN32_SerialPort");

foreach(ManagementObject Port in searcher.Get()) {

string a = (string) Port.GetPropertyValue("Name");

}

Does anybody knows how to get informations about ALL serial ports?

Thanks

Frank
Feb 21 '06 #1
4 17394
Frank wrote:
Hello,

how to get information about all serial ports in the PC?

I use the following code, but i got only the data of the FIRST serial port.
All other serial port information are not available with this code sample:

ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select *
from WIN32_SerialPort");

foreach(ManagementObject Port in searcher.Get()) {

string a = (string) Port.GetPropertyValue("Name");

}

Does anybody knows how to get informations about ALL serial ports?

Thanks

Frank


Sorry, i don't know how to do this over WMI.

You could use CreateFile("COM1", ....) (from kernel32.dll) to try each
possible port (if the returned file handle is -1 the port isn't there.)

Feb 21 '06 #2
Hello Jochen,

your soultion is not suitable for me because i cannot get information, if
the serial port was a native serial port, a USB serial port adapter or a
bluetooth serial port adapter for example. I need specially this
information.

Bye

Frank

"Jochen Albert" <me************@gmx.de> schrieb im Newsbeitrag
news:dt**********@news.cognex.com...
Frank wrote:
Hello,

how to get information about all serial ports in the PC?

I use the following code, but i got only the data of the FIRST serial port. All other serial port information are not available with this code sample:
ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * from WIN32_SerialPort");

foreach(ManagementObject Port in searcher.Get()) {

string a = (string) Port.GetPropertyValue("Name");

}

Does anybody knows how to get informations about ALL serial ports?

Thanks

Frank


Sorry, i don't know how to do this over WMI.

You could use CreateFile("COM1", ....) (from kernel32.dll) to try each
possible port (if the returned file handle is -1 the port isn't there.)

Feb 21 '06 #3
I would like to know that, too. So, if you find a solution... :)
In the Registry theres only the drivers name asociated to a com port,
that may be a clue, but of course no solution.

Frank wrote:
Hello Jochen,

your soultion is not suitable for me because i cannot get information, if
the serial port was a native serial port, a USB serial port adapter or a
bluetooth serial port adapter for example. I need specially this
information.

Bye

Frank

"Jochen Albert" <me************@gmx.de> schrieb im Newsbeitrag
news:dt**********@news.cognex.com...
Frank wrote:
Hello,

how to get information about all serial ports in the PC?

I use the following code, but i got only the data of the FIRST serial port. All other serial port information are not available with this code sample: ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * from WIN32_SerialPort");

foreach(ManagementObject Port in searcher.Get()) {

string a = (string) Port.GetPropertyValue("Name");

}

Does anybody knows how to get informations about ALL serial ports?

Thanks

Frank

Sorry, i don't know how to do this over WMI.

You could use CreateFile("COM1", ....) (from kernel32.dll) to try each
possible port (if the returned file handle is -1 the port isn't there.)


Feb 21 '06 #4
ZS
Hi ,
I'm trying to connect to a Serial port using the Kernel32.dll but having
trouble connecting to the port.
Can you share a simple code as to how you communicate with a serial port. I
appreciate your help.
Thanks
-ZS

"Jochen Albert" wrote:
I would like to know that, too. So, if you find a solution... :)
In the Registry theres only the drivers name asociated to a com port,
that may be a clue, but of course no solution.

Frank wrote:
Hello Jochen,

your soultion is not suitable for me because i cannot get information, if
the serial port was a native serial port, a USB serial port adapter or a
bluetooth serial port adapter for example. I need specially this
information.

Bye

Frank

"Jochen Albert" <me************@gmx.de> schrieb im Newsbeitrag
news:dt**********@news.cognex.com...
Frank wrote:
Hello,

how to get information about all serial ports in the PC?

I use the following code, but i got only the data of the FIRST serial

port.
All other serial port information are not available with this code

sample:
ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select

*
from WIN32_SerialPort");

foreach(ManagementObject Port in searcher.Get()) {

string a = (string) Port.GetPropertyValue("Name");

}

Does anybody knows how to get informations about ALL serial ports?

Thanks

Frank
Sorry, i don't know how to do this over WMI.

You could use CreateFile("COM1", ....) (from kernel32.dll) to try each
possible port (if the returned file handle is -1 the port isn't there.)


Feb 28 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Andreas Horneff | last post: by
3 posts views Thread by collinm | last post: by
13 posts views Thread by Al the programmer | last post: by
3 posts views Thread by Essam | last post: by
3 posts views Thread by naveen.sabapathy | last post: by
4 posts views Thread by cmdolcet69 | last post: by
9 posts views Thread by Hal Vaughan | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.