Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Getting serial ports names problem [modified]

Getting serial ports names problem [modified]

Scheduled Pinned Locked Moved C#
helpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    enginco
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • E enginco

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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 :)

      E 1 Reply Last reply
      0
      • L Lost User

        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 :)

        E Offline
        E Offline
        enginco
        wrote on last edited by
        #3

        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

        L 1 Reply Last reply
        0
        • E enginco

          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

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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 :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups