CreateFile not able to share serial (COM) port
问题 The CreateFile function is useful for opening files or devices for read/write access, providing a handle. The third parameter, dwShareMode , specifies if the file/device can later be accessed by others. An example, with files: void* pFileHandle1 = ::CreateFileA("C:\\test.txt", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); DWORD lastError = GetLastError(); // 0, ERROR_SUCCESS void* pFileHandle2 = ::CreateFileA("C:\\test.txt", GENERIC_READ|GENERIC_WRITE,