diff --git a/src/serialport_win.cpp b/src/serialport_win.cpp index 7e79216a..58c13bcb 100644 --- a/src/serialport_win.cpp +++ b/src/serialport_win.cpp @@ -86,15 +86,10 @@ void OpenBaton::Execute() { strncpy(path, "\\\\.\\", 4); strncpy(path + 4, path + 20, 10); - int shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; - if (lock) { - shareMode = 0; - } - HANDLE file = CreateFile( path, GENERIC_READ | GENERIC_WRITE, - shareMode, // dwShareMode 0 Prevents other processes from opening if they request delete, read, or write access + 0, // dwShareMode 0 (exclusive access) is the only supported mode for Communications Resource NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, // allows for reading and writing at the same time and sets the handle for asynchronous I/O