Delphi使用spcomm串口通信 串口号大于10出错的解决办法 spcomm error opening serial port
2010-02-22 22:42
615 查看
如果你已经会使用SPCOMM且出现10个以上的串口问题
请改一下串口名
COM1.CommName='//./com18';
就这样 加'//./'就行了我也不知道什么回事.......
比如
Comm1.CommName := '//./'+ComboBox1.Text;
//./com18是windows里边的SymbolLinkName,这个在WINAPI里边就需要这
样写,SPCOMM的这部分的源代码如下:
procedure TComm.StartComm;
var
hNewCommFile: THandle;
begin
// Are we already doing comm?
if (hCommFile <> 0) then
raise ECommsError.Create( 'This serial port already opened' );
hNewCommFile := CreateFile( PChar(FCommName), &
lt;------就是这里,要加上//./
GENERIC_READ or GENERIC_WRITE,
0, {not shared}
nil, {no security ??}
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL or FILE_FLAG_OVERLAPPED,
0 {template} );
if hNewCommFile = INVALID_HANDLE_VALUE then
raise ECommsError.Create( 'Error opening serial port' );
^^^^^^^^^^^^^^^^^^^^^^^^^^^如果不是
SymbolLinkName写法,串口号大于9这里就出错了
请改一下串口名
COM1.CommName='//./com18';
就这样 加'//./'就行了我也不知道什么回事.......
比如
Comm1.CommName := '//./'+ComboBox1.Text;
//./com18是windows里边的SymbolLinkName,这个在WINAPI里边就需要这
样写,SPCOMM的这部分的源代码如下:
procedure TComm.StartComm;
var
hNewCommFile: THandle;
begin
// Are we already doing comm?
if (hCommFile <> 0) then
raise ECommsError.Create( 'This serial port already opened' );
hNewCommFile := CreateFile( PChar(FCommName), &
lt;------就是这里,要加上//./
GENERIC_READ or GENERIC_WRITE,
0, {not shared}
nil, {no security ??}
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL or FILE_FLAG_OVERLAPPED,
0 {template} );
if hNewCommFile = INVALID_HANDLE_VALUE then
raise ECommsError.Create( 'Error opening serial port' );
^^^^^^^^^^^^^^^^^^^^^^^^^^^如果不是
SymbolLinkName写法,串口号大于9这里就出错了
相关文章推荐
- windows 8/8.1/10 下prolific usb-to-serial common port quds 无法安装解决办法
- Delphi 在DLL中使用DevExpress控件时出错解决办法
- MyEclipse 打开Struts配置文件时出错的终级解决办法------Error opening the editor.------at org.eclipse.ui.internal.WorkbenchPage.openEditor
- 使用H-Flasher下载出错:error:Flash ID does not match 解决办法 嵌入式家园贺工
- [解决办法]Python中使用json.loads解码字符串时出错:ValueError: Expecting property name: line 1 column 2 (char 1)
- [解决办法]Python中使用json.loads解码字符串时出错:ValueError: Expecting property name: line 1 column 2 (char 1)
- [解决办法]Python中使用json.loads解码字符串时出错:ValueError: Expecting property name: line 1 column 2 (char 1)
- android使用mount命令挂载远程视频文件大于10G,播放时出现卡顿的解决办法
- 32位plsql连接64位oracle 使用命令窗口出错,解决办法
- 在使用UpdatePanel时JS对话框出错的解决办法
- Android项目在Eclipse上运行正常,在AS上出错解决办法(AAPT err(Facade for 1867654195): libpng error: Not a PNG file)
- an error occurred while creating opening the c++ browsing database 解决办法
- C++中使用类模板定义对象时出现:“error LNK2019: 无法解析的外部符号”的解决办法
- 使用 eclipse时,出现如下问题:org.eclipse.swt.SWTError: No more handles的解决办法
- IIS中使用LocalDB遇到错误:error 50,Local Database Runtime error occurred.的解决办法
- 使用 eclipse时,出现如下问题:org.eclipse.swt.SWTError: No more handles的解决办法
- Python下使用MySQLdb连接MySQL出错的解决办法(一)
- GitHub使用过程中push出错的解决办法
- 在win7下使用Delphi调程序的时候突然提示“Unable to create process”,解决办法如下
- 严重: Error listenerStart的解决办法---使用Spring时遇到的问题