unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, CPort;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ComPortRxChar(Sender: TObject; Count: Integer);
private
{ Private declarations }
procedure Delay(MSecs: Longint);
public
{ Public declarations }
end;var
Form1: TForm1;
ComPort1:TComPort;
xx:string;
implementation{$R *.dfm}procedure TForm1.Delay(MSecs: Longint);
var
FirstTickCount, Now: Longint;
begin
FirstTickCount := GetTickCount();
repeat
Application.ProcessMessages;
Now := GetTickCount();
until (Now - FirstTickCount >= MSecs) or (Now < FirstTickCount);
end;procedure TForm1.ComPortRxChar(Sender: TObject; Count: Integer);
begin
// comport1.ReadStr(xx,1024);
end;procedure TForm1.Button1Click(Sender: TObject);
begin
comport1:=TComPort.Create(nil);
comport1.FlowControl.ControlDTR:=dtrEnable;
comport1.Open;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
try
begin
ComPort1.WriteStr('atdt8108'+#13#10);
// Delay(30000);
comport1.ReadStr(xx,1024);
if copy(xx,1,4)='BUSY' then//在这里得到判断相应的拨号返回值
beep;
end;
finally
freeandnil(comport1);
end;
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, CPort;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ComPortRxChar(Sender: TObject; Count: Integer);
private
{ Private declarations }
procedure Delay(MSecs: Longint);
public
{ Public declarations }
end;var
Form1: TForm1;
ComPort1:TComPort;
xx:string;
implementation{$R *.dfm}procedure TForm1.Delay(MSecs: Longint);
var
FirstTickCount, Now: Longint;
begin
FirstTickCount := GetTickCount();
repeat
Application.ProcessMessages;
Now := GetTickCount();
until (Now - FirstTickCount >= MSecs) or (Now < FirstTickCount);
end;procedure TForm1.ComPortRxChar(Sender: TObject; Count: Integer);
begin
// comport1.ReadStr(xx,1024);
end;procedure TForm1.Button1Click(Sender: TObject);
begin
comport1:=TComPort.Create(nil);
comport1.FlowControl.ControlDTR:=dtrEnable;
comport1.Open;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
try
begin
ComPort1.WriteStr('atdt8108'+#13#10);
// Delay(30000);
comport1.ReadStr(xx,1024);
if copy(xx,1,4)='BUSY' then//在这里得到判断相应的拨号返回值
beep;
end;
finally
freeandnil(comport1);
end;
end;end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货