比如,现在我拨号了,开始等待接收事件,有时返回BUSY,有时返回CONNECT,等待时间的如何确定? 那位有源码,参考参考

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/4282/4282441.xml?temp=.629574
      

  2.   


    procedure TForm1.MSComm1Comm(Sender: TObject);
    var
        i,InputLen:Integer;
        tmpInt:Integer;
        tmpvar:Variant;
        InputString:String;
    begin
        if MSComm1.CommEvent=ComEvReceive then
        begin
            InputLen:=MSComm1.InBufferCount;
            //接收二进制数据,转换为十六进制显示
            if HexShow.Checked then
            begin
              MSComm1.InputMode:=1;
              tmpvar:=MSComm1.Input;
              InputString:='';
              for i:= 0 to InputLen-1 do
              begin
                tmpInt:=tmpvar[i];
                InputString:=InputString+' '+IntToHex(tmpint,2);
              end;
            end
            //直接接收字符
            else begin
              MSComm1.InputMode:=0;
              InputString:=MSComm1.Input;
            end;
              memo1.text:=Memo1.Text+Inputstring;
            if InputString='ERROR' then
            begin
              ShowMessage('');
            end;
            showmessage(inputstring);
        end;
    end;procedure TForm1.BitBtn1Click(Sender: TObject);
    var
      str:string;
    begin
      str:=edit1.Text;
      with mscomm1 do
      begin
        if not portopen then
        begin
          portopen:=true;
        end;
        settings:='1200,n,8,1';
        output:=str+chr(10)+chr(13);
     end;
    end;
      

  3.   

    re := RasDialA(nil,nil,@rasparm,0,nil,@rash);
    re = 0 //成功
      

  4.   

    var
    entname,err:pchar;
    re:Dword;
    wx:string;
    begin
    GetMem(err,256);
    entname :=  'd';
    //new(rasparm);
    //new(rash);Label1.Caption := '正在拔号……';
    ZeroMemory(@rasparm,sizeof(trasDIALPARAMS) );
    rasparm.dwSize := sizeof(trasDialParams);if trim(wx) = '' then
       wx := '16900'
    else
       wx := wx + ',16900';CopyMemory(@rasparm.szPhoneNumber[0],pchar(wx),length(wx));
    rasparm.szCallbackNumber := '*';
    rasparm.szPassword := '16900';
    rasparm.szUserName := '16900';rasparm.szDomain :=  '*';//entname := getentname();
    entname := pchar(GetEntName);
    CopyMemory(@rasparm.szEntryName[0],entname,length(entname));
    re := RasDialA(nil,nil,@rasparm,0,nil,@rash);
    if re = 0 then begin
      Dispose(err);
      pr_starttime := Now();
    end else begin
      RasGetErrorStringA(re,err,256);
      //MessageBox(0,err,'拔号失败',MB_OK);
      dm.wf_showpop('拔号失败');
      Dispose(err);
      result := false;
    end;end;