天天看點

C++打開虛拟序列槽失敗

轉自:https://blog.csdn.net/baidu_37503452/article/details/87004621

// get a handle to the port

m_hComm = CreateFile(_T("\\.\COM11"), // communication port string (COMX)

GENERIC_READ | GENERIC_WRITE, // read/write types

0, // comm devices must be opened with exclusive access

NULL, // no security attributes

OPEN_EXISTING, // comm devices must use OPEN_EXISTING

FILE_FLAG_OVERLAPPED, // Async I/O

0); // template must be 0 for comm devices

if (m_hComm == INVALID_HANDLE_VALUE)

{

// port not found

delete [] szPort;

delete [] szBaud;

return FALSE;

}

com10以上,CreateFile的第一個參數要變成\\.\ + COM11

C++打開虛拟序列槽失敗

繼續閱讀