是用SPCOMM控件进行串口通信,但是在运行的时候程序总是会报出access violation at address in module这样的错误,不知道这是怎么回事呢?单步运行的时候因为我不太懂,所以看不出问题在哪里,高手能不能给解答一下,我第一次做串口这的东西,还不是太熟悉!谢谢了,我的代码是这样的unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, SPComm, StdCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Comm1: TComm;
    Memo1: TMemo;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
  Comm1: TComm;
  Memo1: TMemo;
  viewstring:string;
i:integer;
rbuf,sbuf:array[1..256] of byte;implementation{$R *.dfm}procedure senddata;
var
i:integer;
commflg:boolean;
begin
viewstring:='';
commflg:=true;
for i:=1 to 6 do
begin
if not comm1.writecommdata(@sbuf[i],1) then
begin
commflg:=false;
break;
end;
//发送时字节间的延时
sleep(2);
viewstring:=viewstring+inttohex(sbuf[i],2)+' ';
end;
viewstring:='发送'+viewstring;
memo1.lines.add(viewstring);
memo1.lines.add('');
if not commflg then messagedlg('发送失败',mterror,[mbyes],0);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
  sbuf[1]:=byte($f0); //帧头
  sbuf[2]:=byte($01); //命令号
  sbuf[3]:=byte($ff);
  sbuf[4]:=byte($ff);
  sbuf[5]:=byte($01);
  sbuf[6]:=byte($f0); //帧尾
  senddata;//调用发送函数
end;procedure TForm1.Button1Click(Sender: TObject);
begin
  comm1.StopComm;
  comm1.StartComm;
end;end.
就一个小例子