473,395 Members | 1,872 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,395 software developers and data experts.

Using ManagementObjectSearcher for serial port list

I'm using the following code in an attempt to obtain a list of available
serial ports.
I expected to retrieve the same values as listed in hardware manager in
Control panel but I'm not.
I'm being returned COM1 and COM3 when I should be receiving COM1 and COM4.
I've also a USB to serial converter and although listed in control panel
correctly again my query is not returning this device.
What am I doing wrong please?

public void FillDeviceList(ComboBox.ObjectCollection cb)
{
cb.Clear();
SelectQuery selectQuery = new SelectQuery("select * from Win32_SerialPort");
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(selectQuery);
//System.Array result
foreach (ManagementObject disk in searcher.Get())
{
cb.Add(disk["DeviceID"].ToString());
}
}
Nov 16 '05 #1
2 14495
Claire, I think this has to do with physical as against virtual ports

My notebook PC hos no hardware COM ports, but the hardware manager shows 3 virtual ports (COM4, COM5, COM6)
Your query returns nothing
On the other hand, I have 4 physical USB ports. These are listed when I use the "Win32_USBHub" query

In your case if you have only 1 physical COM port, it will be both COM1 and COM3
Your USB to serial converter will be a virtual COM port that's why it doesn't show.
Nov 16 '05 #2
thanks crater,
that answers why i'm getting com3.
So my problem is how to query for virtual com ports and how to filter out
ports like com3.
If microsoft achieve this then I should be able to do the same if I knew
what I was looking for.
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: ^CeFoS^ | last post by:
Hello to everybody, I've done an application that draws in a frame the trajectory of a robot. The robot position is readed through the serial port, and several commands are wrote through the...
1
by: Junior | last post by:
I keep receiving this "The type or namespace name 'CASsEventHandler' could not be found (are you missing a using directive or an assembly reference?)" message in two particular lines, and I've...
11
by: sarah | last post by:
hI, I have a project. I need to realise serial communication between PC and Altera FPGA in c or c++. The function of FPGA is working well. it can send data to uart. Does anybody know how to...
11
by: Michael Tallhamer | last post by:
I am a medical physicist new to the .Net Framework and am trying to write a simple app that will monitor the output from a serial port on one of my linear accelerators using the new Serialport...
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. ...
6
by: ransoma22 | last post by:
I developing an application that receive SMS from a connected GSM handphone, e.g Siemens M55, Nokia 6230,etc through the data cable. The application(VB.NET) will receive the SMS automatically,...
13
by: Rob | last post by:
Hi all, I am fairly new to python, but not programming and embedded. I am having an issue which I believe is related to the hardware, triggered by the software read I am doing in pySerial. I...
1
by: lutherchp | last post by:
A baffling end to my week! I open my serial port on my Debian PC (Debian version 5.0.1) I have a decent Null Modem lead going to another PC (I'll call it PC#2), with its port open with the same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.