用CreateFile打开串口超过com10就不能 发布时间: 2012-05-29 12:16:00 作者: rapoo
用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);