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();