首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

用CreateFile打开串口超过com10就不能打开解决方法

2012-05-29 
用CreateFile打开串口超过com10就不能打开一台机子用moxa的两块8口的串口扩展卡,扩展了16个串口,在硬件管

用CreateFile打开串口超过com10就不能打开
一台机子用moxa的两块8口的串口扩展卡,扩展了16个串口,在硬件管理器里也能看到这16个串口,但是用CreateFile打开串口时,com10及以上的串口打开失败,GetLastError()为 2,说明没有找到串口,不知道这是什么原因?


[解决办法]
这样就可以了
CreateFile(
"\\\\.\\COM10", // address of name of the communications device
fdwAccess, // access (read-write) mode
0, // share mode
NULL, // address of security descriptor
OPEN_EXISTING, // how to create
0, // file attributes
NULL // handle of file with attributes to copy
);

[解决办法]

探讨
这样就可以了
CreateFile( 
              "\\\\.\\COM10",          //  address  of  name  of  the  communications  device 
              fdwAccess,                    //  access  (read-write)  mode 
              0,                                    //  share  mode 
              NULL,                              //  address  of  security  descriptor 
              OPEN_EXISTING,            //  how  to  create 
              0,                                    //  file  attributes 
              NULL                                //  handle  of  file  with  attributes  to  copy 
        ); 


[解决办法]
楼上方法对的。
[解决办法]
\\\\.\\com10
[解决办法]
学习
[解决办法]
C/C++ code
  CString lpszPortName = _T("");  if(PortNum < 10)   lpszPortName.Format( _T("COM%d"), PortNum );  else   lpszPortName.Format( _T("\\\\.\\COM%d"), PortNum); 

热点排行