Get Arduino Usb Com Ports With C#

Hi I use this code for getting available com ports from computer with C#

string[] ports = SerialPort.GetPortNames();
foreach (string port in ports)
{
comboBox1.Items.Add(port);
}

My question is that How can I get only Arduino port because I get all ports and I take exception on my desktop program. I want to take only arduino ports.

Anybody have idea?

Desktop program: Send startbyte and a char (i for info) and wait for answere

Arduino: wait for command. If startbyte and char i received answer with a char or string like firmware version.

I FOund :smiley:

here is code

try
{
comboBox1.Items.Clear();
ManagementObjectSearcher searcher =
new ManagementObjectSearcher(“root\CIMV2”,
“SELECT * FROM Win32_PnPEntity”);

            foreach (ManagementObject queryObj in searcher.Get())
            {
                if (queryObj["Caption"].ToString().Contains("Arduino"))
                {
                    Console.WriteLine(queryObj["Caption"]);
                }

            }
            Console.ReadLine();
        }
        catch (ManagementException e)
        {
            Console.WriteLine(e.Message);
        }