清讲讲我为什么打不开com2
由于鼠标占用com1,故我用com2,2口未接任何外设
我在from.creat写了:
comm1.commname:=2;
comm1.StartComm;
comm1.WriteCommData('abcdef',6);
在comm1SendDataEmpty里写了:
showmessage('over');
运行后总是出错: 'error open serial port'
我怀疑是2口已打开,故将comm1.startcomm注释
但若把 comm1.startcomm 注释掉后编译可通过,没有'over'的提示
哪位说说我错在哪里?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
SPComm;
type
TForm1 = class(TForm)
Comm1: TComm;
procedure FormCreate(Sender: TObject);
procedure Comm1SendDataEmpty(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
comm1.commname:=2;
comm1.StartComm;
comm1.WriteCommData('abcdef',6);
end;
procedure TForm1.Comm1SendDataEmpty(Sender: TObject);
begin
showmessage('over');
end;
end.