473,246 Members | 1,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,246 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 17731
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Andreas Horneff | last post by:
Hi @ all, I've got a problem with serial communication in Borland C++ Builder. I've already found a lot of stuff about serial communication in the internet, but it dosen't work. What I want...
3
by: collinm | last post by:
hi i send a command to a led display, the led display is suppose to return me some character i write a string on a serial port void ledDisplayExist() { char msg={'\0', '\0', '\0', '\0',...
13
by: Al the programmer | last post by:
I need to access the serial ports on my webserver from an asp.net page. I have no problem accessing the serial ports from a windows form application, but the code doesn't work in asp.net. I have...
4
by: joe bloggs | last post by:
I am writing a mobile application to interface with a legacy system and I am planning to use web services to communicate with this system. The legacy system receives data through a serial port. ...
3
by: Essam | last post by:
Hi All I have two programs ; both of them I need to give read/write access to the same Comm Port. How can I do so; using Code or third party tool/library
3
by: naveen.sabapathy | last post by:
Hi, I am trying to use virtual serial ports to develop/test my serial communication program. Running in to trouble... I am using com0com to create the virtual ports. The virtual ports seem to...
4
by: cmdolcet69 | last post by:
This code below write a serial command to the com port then read the results and disaplays it into the label1.text property when button1_click event is triggered. I think what is going on is that...
9
by: Hal Vaughan | last post by:
I've done a fair amount of Googling for information on reading the serial port in C++ (and in Linux). Unfortunately, out of every 4 hits, 1 seems to be an unanswered question, 1 is someone saying,...
4
by: JDS | last post by:
I have an application that interfaces with a USB device using the .Net serial port. The code works fine, displaying live data on the screen; that is until the USB lead is pulled out from the PC...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.