Getting serial ports names problem [modified]
-
Hi, I'm getting serial ports names with the following code:
System.IO.Ports.SerialPort.GetPortNames();
It gives COM1 and COM3, but the problem is, COM3 doesn't exist under "DeviceManager -> Ports". (After restart) Any suggestions?
I want to fly but I don't have wings
modified on Thursday, June 11, 2009 3:18 AM
-
Hi, I'm getting serial ports names with the following code:
System.IO.Ports.SerialPort.GetPortNames();
It gives COM1 and COM3, but the problem is, COM3 doesn't exist under "DeviceManager -> Ports". (After restart) Any suggestions?
I want to fly but I don't have wings
modified on Thursday, June 11, 2009 3:18 AM
-
Do you have an internal WinModem? These sometimes create a virtual COM port which will not be shown in the Device Manager. Take a look at the modem-properties in the configuration-screen.
I are troll :)
Yes, you are right. I have hdaudio data fax modem, its port is com3, and some ports are in use (com5, com6) But com3 is not in use. When I pluged usb-serial adaptor in notebook, com3 is appearing under "Ports". After, I can use this port. If modem is using or reserved (but com3 not in use) the port, how did adaptor take this port? So, How can I get correct port list (without com3)? Thanks...
I want to fly but I don't have wings
-
Yes, you are right. I have hdaudio data fax modem, its port is com3, and some ports are in use (com5, com6) But com3 is not in use. When I pluged usb-serial adaptor in notebook, com3 is appearing under "Ports". After, I can use this port. If modem is using or reserved (but com3 not in use) the port, how did adaptor take this port? So, How can I get correct port list (without com3)? Thanks...
I want to fly but I don't have wings
enginço wrote:
So, How can I get correct port list (without com3)?
You can give
System.Management
a try, I have used it before to enumerate hardware. I don't know for sure whether virtual com-ports are included, and I can't test it on my own machine (at least not without installing a new com-port). You'd need to add a reference to the assembly "System.Management" to use this functionality. The code would be something like this;ManagementObjectSearcher searcher =
new ManagementObjectSearcher("SELECT Name FROM Win32_SerialPort");foreach (ManagementObject mo in searcher.Get())
Console.WriteLine(mo.GetPropertyValue("Name"));Console.ReadKey();
Alternatively, you could scan the registry. Open RegEdit and search for the friendly name of the COM-port :)
I are troll :)