From 10d47de9b86e1fe4a112ad40870aebc44be4e3bb Mon Sep 17 00:00:00 2001 From: jie Date: Thu, 7 Nov 2024 17:24:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=B2=E5=8F=A3=E6=89=AB?= =?UTF-8?q?=E6=8F=8F=E5=87=BD=E6=95=B0=E6=97=A0=E6=B3=95=E6=89=AB=E6=8F=8F?= =?UTF-8?q?=E5=88=B0=E5=B7=B2=E7=BB=8F=E8=A2=AB=E6=89=93=E5=BC=80=E7=9A=84?= =?UTF-8?q?=E4=B8=B2=E5=8F=A3=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/serial.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/serial.h b/include/serial.h index 6ddc17f..1745e57 100644 --- a/include/serial.h +++ b/include/serial.h @@ -94,8 +94,10 @@ namespace serial { comname.c_str(), static_cast(GENERIC_WRITE) | GENERIC_READ, 0U, nullptr, OPEN_EXISTING, 0U, nullptr); if (m_handle != INVALID_HANDLE_VALUE) { - portArray.push_back(showname); + portArray.emplace_back(showname); CloseHandle(m_handle); + }else if(GetLastError() == ERROR_ACCESS_DENIED){ + portArray.emplace_back(showname); } comname.clear(); showname.clear();