Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys ,

I tried The code below.but doesnt return anything..what can be reason for it ?


please give me advice..Thanks for helping


C#
try
          {
              ManagementObjectCollection mReturn;
              ManagementObjectSearcher mSearch;
              mSearch = new ManagementObjectSearcher("Select * from Win32_SerialPort");
              mReturn = mSearch.Get();
              foreach (ManagementObject mObj in mReturn)
              {
                  numberList.Items.Add(mObj["Caption"].ToString());
              }
          }
          catch (Exception t)
          {

          }
Posted
Comments
Christian Graus 13-Nov-12 12:52pm    
Your question has nothing to do with list boxes. It has to do with WMI and the serial port. Do you have things attached to serial ports when you run this code ?

1 solution

Why not just use the SerialPort.GetPortNames[^] method?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900