473,769 Members | 4,202 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:

ManagementObjec tSearcher searcher = new ManagementObjec tSearcher("Sele ct *
from WIN32_SerialPor t");

foreach(Managem entObject Port in searcher.Get()) {

string a = (string) Port.GetPropert yValue("Name");

}

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

Thanks

Frank
Feb 21 '06 #1
4 17818
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:

ManagementObjec tSearcher searcher = new ManagementObjec tSearcher("Sele ct *
from WIN32_SerialPor t");

foreach(Managem entObject Port in searcher.Get()) {

string a = (string) Port.GetPropert yValue("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("COM 1", ....) (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:
ManagementObjec tSearcher searcher = new ManagementObjec tSearcher("Sele ct * from WIN32_SerialPor t");

foreach(Managem entObject Port in searcher.Get()) {

string a = (string) Port.GetPropert yValue("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("COM 1", ....) (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: ManagementObjec tSearcher searcher = new ManagementObjec tSearcher("Sele ct * from WIN32_SerialPor t");

foreach(Managem entObject Port in searcher.Get()) {

string a = (string) Port.GetPropert yValue("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("COM 1", ....) (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:
ManagementObjec tSearcher searcher = new ManagementObjec tSearcher("Sele ct

*
from WIN32_SerialPor t");

foreach(Managem entObject Port in searcher.Get()) {

string a = (string) Port.GetPropert yValue("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("COM 1", ....) (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
8846
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 to do: I want to connect only one button to my com port. If the button is pressed,
3
5055
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', '\0', '\1', 'Z', '0', '0',
13
4833
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 been told it is not possible to access the serial ports from asp.net. The application is used to control custom hardware. The hardware is connected to a PC through serial ports. Our customer wants to control the hardware from a remote...
4
11207
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. What I would like to do is make the serial port accessible via a web service. The web service and the legacy application would be running on the same machine. The mobile application would access the web service via a network connection. It...
3
3293
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
11632
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 be working fine when I test it with Hyperterminal . I am using the example program that comes with pyserial, as below. --------------- import serial
4
5447
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 the ocp.read is on a timer and reads char by char. How can i change this code so that the read reads the whole result and not char by char? Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
9
14402
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, "That's easy, there's a lot out there, Google it,", 1 is a discussion on it without examples and the other is who knows what. I did find some info on it and have been experimenting. The one example that I liked the best in terms of...
4
4779
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 when the program hangs. The obvious answer is not to pull the lead out, but unfortunately the application is one in which there is a high possibility the lead will be pulled out so the code needs to be more robust. The form has a timer...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.