Hi, The problem has finally caught me again by the hooks. The following code works for only physical COM ports installed ==== >ManagementClass mc = new ManagementClass("Win32_SerialPort"); >System.Management.ManagementObjectCollection moc = mc.GetInstances(); >foreach (ManagementObject port in moc) >{ > MessageBox.Show("Port = " + port["deviceid"]); >} ====
I need to get the COM port on the USB and PCI as well.(All logical ports) Any one can provde any pointers as to which "Win32_********" Management class to use? Regards, Vipul Patel -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Kevin Hood Sent: Wednesday, May 05, 2004 10:38 PM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] .NET function for finding out COM ports on a PC All: I tried Vipul's suggestion on my computer and it worked fine until I installed a USB serial port device. The original poster's solution of looking in the registry showed the new device just fine on COM4 which also showed up in the control panel by navigating to: System - Hardware - Device Manager - Ports (COM & LPT). However, the new COM4 did not show up using the ManagementClass method. I presume that there must be yet another way to find all logical COM devices installed. :Kevin Kevin Hood Advanced Bionics Corp. >Hi, > >The solution lied in the System.Management namespace. > >ManagementClass mc = new ManagementClass("Win32_SerialPort"); >System.Management.ManagementObjectCollection moc = mc.GetInstances(); >foreach (ManagementObject port in moc) >{ > MessageBox.Show("Port = " + port["deviceid"]); >} =================================== This list is hosted by DevelopMentorŪ http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorŪ http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com