17 Şubat 2019 Pazar

C# SeriPort Ad okuma

using (var searcher = new System.Management.ManagementObjectSearcher
                ("SELECT * FROM WIN32_SerialPort"))
            {
                string[] portnames = System.IO.Ports.SerialPort.GetPortNames();
                var ports = searcher.Get().Cast<System.Management.ManagementBaseObject>().ToList();
                var tList = (from n in portnames
                             join p in ports on n equals p["DeviceID"].ToString()
                             select n + " - " + p["Caption"] ).ToList();

                   tList.ForEach(Console.WriteLine);
            }

Hiç yorum yok: