A
activewy
Unregistered / Unconfirmed
GUEST, unregistred user!
大家帮我看看以下代码:
procedure TForm1.Button1Click(Sender: TObject);
var
PhoneNumber : string;
CommPort : string;
NumberWritten : LongInt;
hCommFile : THandle;
begin
PhoneNumber := 'ATDT163' + #13 + #10;
CommPort := 'COM2';
{打开com口}
hCommFile := CreateFile(PChar(CommPort),
GENERIC_WRITE,
0,
nil,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
if hCommFile=INVALID_HANDLE_VALUE then
begin
ShowMessage('不能打开'+ CommPort);
exit;
end;
{拨号}
NumberWritten:=0;
if WriteFile(hCommFile,
PChar(PhoneNumber)^,
Length(PhoneNumber),
NumberWritten,
nil) = false then begin
ShowMessage('不能写' + CommPort);
end;
end;
我的问题是:
在用AT指令拨号后,怎样得到modem返回的结果码?例如:没有拨号音为NO
DIALTONE;
是否要另开一个线程,临测modem所在的Com口才能做到?
procedure TForm1.Button1Click(Sender: TObject);
var
PhoneNumber : string;
CommPort : string;
NumberWritten : LongInt;
hCommFile : THandle;
begin
PhoneNumber := 'ATDT163' + #13 + #10;
CommPort := 'COM2';
{打开com口}
hCommFile := CreateFile(PChar(CommPort),
GENERIC_WRITE,
0,
nil,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
if hCommFile=INVALID_HANDLE_VALUE then
begin
ShowMessage('不能打开'+ CommPort);
exit;
end;
{拨号}
NumberWritten:=0;
if WriteFile(hCommFile,
PChar(PhoneNumber)^,
Length(PhoneNumber),
NumberWritten,
nil) = false then begin
ShowMessage('不能写' + CommPort);
end;
end;
我的问题是:
在用AT指令拨号后,怎样得到modem返回的结果码?例如:没有拨号音为NO
DIALTONE;
是否要另开一个线程,临测modem所在的Com口才能做到?