请问如何获取串口列表,包括232和485串口等等?
请问如何获取串口列表,包括232和485串口等等,就像在硬件管理中看到的一样? 问题点数:50、回复次数:4Top
1 楼stepman(骆哈哈)回复于 2006-08-17 21:59:52 得分 10
用下面的代码试试
foreach (string s in SerialPort.GetPortNames())
{
//Console.WriteLine(" {0}", s);
label1.Text += s;
}
想写到哪里你自己看着办就行了Top
2 楼tianjh(關東闔)回复于 2006-10-24 15:36:13 得分 15
这家伙肯定是新手,还不习惯用常规武器:
这是.Net 2.0MSDN里面的:
using System;
using System.IO.Ports;
namespace SerialPortExample
{
class SerialPortExample
{
public static void Main()
{
// Get a list of serial port names.
string[] ports = SerialPort.GetPortNames();
Console.WriteLine("The following serial ports were found:");
// Display each port name to the console.
foreach(string port in ports)
{
Console.WriteLine(port);
}
Console.ReadLine();
}
}
}
Top
3 楼BSC(VirtualCat)回复于 2006-10-24 16:22:49 得分 15
String[] ports = SerialPort.GetPortNames();Top
4 楼dunao([別人騎馬,俺騎驢,比上不足,比下有余])回复于 2006-11-01 11:01:52 得分 10
楼上正解Top




