From 809f7e0021dbb7a0e5b2f67d54da2298f30a53c3 Mon Sep 17 00:00:00 2001 From: Denis Barkar Date: Tue, 15 Apr 2025 20:25:40 +0200 Subject: Serial: Fixed UWP build (#289) --- src/chips/opl_serial_misc.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/chips/opl_serial_misc.h b/src/chips/opl_serial_misc.h index a504a26..9fcd2e9 100644 --- a/src/chips/opl_serial_misc.h +++ b/src/chips/opl_serial_misc.h @@ -282,7 +282,19 @@ public: this->close(); std::string portPath = "\\\\.\\" + portName; - m_port = CreateFileA(portPath.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + std::wstring wportPath; + wportPath.resize(portPath.size()); + int newSize = MultiByteToWideChar(CP_UTF8, + 0, + portPath.c_str(), + (int)portPath.size(), + (wchar_t *)wportPath.c_str(), + (int)wportPath.size()); + m_port = CreateFile2(wportPath.c_str(), GENERIC_WRITE, 0, OPEN_EXISTING, NULL); +#else + m_port = CreateFileA(portPath.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); +#endif if(m_port == INVALID_HANDLE_VALUE) { -- cgit v1.2.3