在listBox中列出端口号和连接的设备? [英] listing port number and connected device to the listBox ?
本文介绍了在listBox中列出端口号和连接的设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我尝试了下面的代码.但没有返回任何内容.
请给我建议.谢谢您的帮助
Hi guys ,
I tried The code below.but doesnt return anything..what can be reason for it ?
please give me advice..Thanks for helping
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)
{
}
推荐答案
为什么不只使用 ^ ]方法?
Why not just use the SerialPort.GetPortNames[^] method?
这篇关于在listBox中列出端口号和连接的设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文