可以利用RXLIB控件,然后在参考以下程序:
unit formMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, VaClasses, VaComm, ExtCtrls, Menus;
type
TForm1 = class(TForm)
VaComm1: TVaComm;
Label1: TLabel;
Label2: TLabel;
Timer1: TTimer;
procedure VaComm1RxChar(Sender: TObject; Count: Integer);
procedure FormCreate(Sender: TObject);
procedure VaComm1Ring(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Label1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
Var
Finished: boolean;
CallerID,
Call_Date,
Call_Time:String[50];
procedure TForm1.VaComm1RxChar(Sender: TObject; Count: Integer);
Var
S:string[50];
begin
S:=VaComm1.ReadText;
if Not Finished then
begin
CallerID:=CallerID+copy(S,0,length(S)-2);
Finished:=True;
Label1.Caption:=CallerID;
end;
if Copy(S,0,4)='NMBR' then
begin
CallerID:=copy(S,8,length(S));
if copy(S,length(S),1)=#10 then
Begin
Finished:=True;
end
else Finished:=False;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Finished:=True;
Form1.Top:=Label1.Top;
Form1.Left:=Label1.Left;
Form1.Height:=Label1.Height*2;
Form1.Width:=Label1.Width+Label2.Width;
VaComm1.WriteText('AT#CLS=8#CID=1'+#13#10);
end;
procedure TForm1.VaComm1Ring(Sender: TObject);
begin
Label2.Caption:='来电...';
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Not Vacomm1.RING then Label2.Caption:='';
end;
procedure TForm1.Label1Click(Sender: TObject);
begin
Label1.Caption:='';
end;
end.