串口号为COM11,通过WinAPI始终无法打开串口,才发现原因如下:

http://www.advancedvirtualcomport.com/faq.html

How do I open a virtual serial port with a number higher than 9 from my application?
Windows automatically maps COM1-COM9 ports to the right device name. COM ports with higher numbers should be opened as \\.\COMxxx, where xxx is a port number.

Example for C/C++/C#: 
hPort = CreateFile("\\\\.\\COM15", ...); 

Example for VB: 
hPort = CreateFile("\\.\COM15", ...); 

Example for Delphi: 
hPort := CreateFile('\\.\COM15', ...);


另发现:如果出现1~9 COM port打不开,可能会因为是之前打开后忘记关闭了,系统自动映射会有记录,再次打开时无法成功打开,需要关闭该COM口或者重启电脑(比较裸)。

 

相关文章:

  • 2021-07-15
  • 2021-11-10
  • 2021-09-12
  • 2021-04-16
  • 2022-02-07
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
猜你喜欢
  • 2021-06-19
  • 2021-04-24
  • 2021-08-04
  • 2021-09-10
  • 2022-03-04
  • 2022-02-14
  • 2022-12-23
相关资源
相似解决方案