注册 登录
编程论坛 Delphi论坛

MSCom串口编程 求助

hlxjw2001 发布于 2005-05-07 15:31, 1329 次点击
MSCom串口编程
你们好,我现在在用MSComm串口编程,我有点问题想请教你们。 procedure TForm1.Button1Click(Sender: TObject); begin if mscomm1.PortOpen=false then begin mscomm1.PortOpen:=true; end; mscomm1.Settings:='9600,n,8,1'; mscomm1.InBufferSize:=1024; mscomm1.InBufferCount:=0; mscomm1.InputMode:=1; mscomm1.InputLen:=0; mscomm1.Output:='AT+CSCA=+8613800311500'; mscomm1.Output:='AT+CMGF=1'; mscomm1.Output:='AT+CMGS=+8613722347848'; mscomm1.Output:='successfull'; end; 但是一单击按钮不是弹出“Project project1.exe raised exception class EOleException with message 'port already open',process stopped,use step or run to continue."就是弹出“Project project1.exe raised exception class EOleException with message 'The devic is not open',process stopped,use step or run to continue." 请问一下这问题出在什么地方。我这是用数据线把手机和电脑连起来,用上面的程序实现发短信的功能。 请高手不吝赐教。
2 回复
#2
pzlyj2005-05-15 11:48
可能是串口名不对,
用SPCOMM不错.
#3
luperfect2005-05-21 22:28
我已经给你回复过,你应先设置,后打开串口.mscomm1.portopen:=true放到最后,就OK了.
1