Saturday , July 27 2024

Liệt kê các cổng COM (COM Port) trong C#

Để liệt kê các cổng COM có trong máy tính của bạn thì bạn chỉ cần sử dụng phương thức GetPortNames() của lớp SerialPort.

Cách làm như sau:

public void getPortName()
{
/* Get available serial ports */
Console.WriteLine("Available Ports: ");
foreach (string portName in SerialPort.GetPortNames())
{
Console.WriteLine(portName);
}
}

Chúc các bạn vui vẻ!

About Ngo Thang IT

Một bình luận

  1. I simply want to tell you that I am newbie to weblog and seriously savored your page. Almost certainly I’m going to bookmark your website . You amazingly come with outstanding writings. Thanks a lot for sharing your webpage.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Đăng Ký Nhận Tin Qua Email

Nhận thông tin bổ ích về WordPress, Hosting, Thủ thuật website, Download miễn phí....và các phần quà hấp dẫn qua email.

* là bắt buộc