C#獲取本地串列埠裝置

jackwu74發表於2024-03-29

RegistryKey keyCom = Registry.LocalMachine.OpenSubKey("Hardware\\DeviceMap\\SerialComm");
if (keyCom != null)
{

string[] sSubKeys = keyCom.GetValueNames();
foreach (string sName in sSubKeys)
{
string sValue = (string)keyCom.GetValue(sName);
Console.WriteLine(sValue);

//或者

SerialPort.GetPortNames().ToList();

相關文章