拨号程序很多,占线可以判断出来,至于自动安装驱动那是不行的
我曾做了一个简单的拨号程序,源程序如下:
StrPCopy(ATCommand,'ATZ'+#13); //初始化
WriteFile(ComList[Param.Port],ATCommand,StrLen(ATCommand),WSize,Nil);
StrPCopy(ATCommand,'ATE0'+#13);
WriteFile(ComList[Param.Port],ATCommand,StrLen(ATCommand),WSize,Nil);
StrPCopy(ATCommand,'ATV1'+#13);
WriteFile(ComList[Param.Port],ATCommand,StrLen(ATCommand),WSize,Nil);
StrPCopy(ATCommand,'ATQ0'+#13);
WriteFile(ComList[Param.Port],ATCommand,StrLen(ATCommand),WSize,Nil);
PurgeComm(ComList[Param.Port],PURGE_RXCLEAR);
StrPCopy(ATCommand,'ATDT'+StrPas(Param.No)+#13); //拨号
WriteFile(ComList[Param.Port],ATCommand,StrLen(ATCommand),WSize,Nil);
DTime:=timeGetTime+Param.Time; //拨号时间
Memory:=TMemoryStream.Create;
While DTime > timeGetTime Do
Begin
ClearCommError(ComList[Param.Port],WSize,@State);
if State.cbInQue>0 Then
Begin
GetMem(Recv,State.cbInQue);
ReadFile(ComList[Param.Port],Recv^,State.cbInQue,WSize,Nil);
Memory.Write(Recv^,State.cbInQue);
FreeMem(Recv,State.cbInQue);
Memory.Write(TerminateByte,1);
Memory.Seek(-1,soFromEnd);
if StrPos(PChar(Memory.Memory),'CONNECT')<>Nil Then //已连接
Begin
StrPCopy(ATCommand,'CONNECT');
Break;
End;
if StrPos(PChar(Memory.Memory),'BUSY')<>Nil Then //忙音
Begin
StrPCopy(ATCommand,'BUSY');
Break;
End;
if StrPos(PChar(Memory.Memory),'NO DIALTONE')<>Nil Then //无拨号音
Begin
StrPCopy(ATCommand,'NO DIALTONE');
Break;
End;
if StrPos(PChar(Memory.Memory),'NO CARRIER')<>Nil Then //无载波
Begin
StrPCopy(ATCommand,'NO CARRIER');
Break;
End;
End;
End;