看你用的什么语音卡,一般都是有SDK读取的。

解决方案 »

  1.   

    找到代码,仅供参考。
    var s,TelPhone:string;
        i:integer;
    begin
      TelPhone:='';
      S:=DBGrid1.SelectedField.AsString;
      for i:=1 to Length(S) do
      begin
        if  (48<=Ord(S[I])) and  (Ord(S[I])<=57) then // 有效数字0123456789
        TelPhone:=TelPhone+S[I];
      end;
      if length(TelPhone)<2 then exit;
      with CallParams do
      begin
        dwTotalSize := sizeof(CallParams);
        dwBearerMode := LINEBEARERMODE_VOICE;                
        dwMediaMode:=LINEMEDIAMODE_INTERACTIVEVOICE;
      end;
      if lineInitialize(@lineApp,HInstance,@lineCallBack,'',nDevs)<0
        then showmessage('线路不能初始化!')
        else if nDevs=0 // 无TAPI设备
              then begin
                    lineShutDown(lineApp);
                    lineApp:=0;
                  end
             else       // 协商TAPI版本号 TAPI1.4¡«TAPI2.0
               if lineNegotiateAPIVersion(lineApp,0,$00010004,$00020000,
                  tapiVersion,extid)<0
                 then begin
                        showmessage('TAPI版本不兼容!');
                        lineShutDown(lineApp);
                        lineApp:=0;
                      end
                 else errorcode:=lineOpen(lineApp,LINEMAPPER,@line,tapiVersion,0,0,LINECALLPRIVILEGE_NONE,LINEMEDIAMODE_INTERACTIVEVOICE,@CallParams);  // 打开线路
      if errorcode<0
        then showmessage('线路不能打开!')
        else begin      // 线路成功打开 
               lineConfigDialog(0,Self.Handle,nil); 
               lineGetIcon(0,'tapi/line',@lineIcon);
               if lineMakeCall(line,@call,PChar(TelPhone),0,@CallParams)<0
                 then showmessage('呼叫失败!')
                 else begin
                        showmessage('请摘机通话!');
                        lineHandOff(call,'µç»°²¦ºÅ³ÌÐò',LINEMEDIAMODE_INTERACTIVEVOICE);
                        lineShutDown(lineApp);
                      end;
             end;end;
      

  2.   

    调用函数:
    procedure lineCallback(hDevice, dwMsg, dwCallbackInstance,
         dwParam1, dwParam2, dwParam3: LongInt); stdcall;//Òì²½ºô½Ð·µ»Ø´¦Àíº¯Êý
    var Call: HCall;
    begin
      if dwMsg = LINE_REPLY then 
      if dwParam2 < 0 then
      showmessage('呼叫响应错误!')
      else
      if dwMsg = LINE_CALLSTATE then  begin
      Call := HCall(hDevice);    case dwParam1 of
        LINECALLSTATE_IDLE: 
                         if call <> 0 then
                         begin
                           lineDeallocateCall(Call);
                         end;
        LINECALLSTATE_PROCEEDING:showmessage('呼叫正常处理!');
        LINECALLSTATE_DIALTONE:showmessage('检测到拔号音!');
        LINECALLSTATE_DIALING: showmessage('正在拔号!');
        LINECALLSTATE_DISCONNECTED:
                                 begin
                                  if dwParam2=LINEDISCONNECTMODE_NORMAL then showmessage('正常断开')
                                  else
                                  if dwParam2=LINEDISCONNECTMODE_BUSY then showmessage('线路忙');
                                 end;
         LINECALLSTATE_BUSY:showmessage('线路忙处理');
       end;
      end;
    end;
      

  3.   

    第要硬件支持,硬件厂家会供相应的SDK开发包和示例,你要想凭空实现。可以等待到2300年不一定!
      

  4.   

    我的代码,硬件需要:支持拔号上网的猫。
    重新上传,DBGrid的鼠标右键事件:
    var s,TelPhone:string;
        i:integer;
    begin
      TelPhone:='';
      S:=DBGrid1.SelectedField.AsString;
      for i:=1 to Length(S) do
      begin
        if  (48<=Ord(S[I])) and  (Ord(S[I])<=57) then // 有效数字0123456789
        TelPhone:=TelPhone+S[I];
      end;
      if length(TelPhone)<2 then exit;
      with CallParams do
      begin
        dwTotalSize := sizeof(CallParams);
        dwBearerMode := LINEBEARERMODE_VOICE;                
        dwMediaMode:=LINEMEDIAMODE_INTERACTIVEVOICE;
      end;
      if lineInitialize(@lineApp,HInstance,@lineCallBack,'',nDevs)<0
        then showmessage('线路不能初始化!')
        else if nDevs=0 // 无TAPI设备
              then begin
                    lineShutDown(lineApp);
                    lineApp:=0;
                  end
             else       // 协商TAPI版本号 TAPI1.4¡«TAPI2.0
               if lineNegotiateAPIVersion(lineApp,0,$00010004,$00020000,
                  tapiVersion,extid)<0
                 then begin
                        showmessage('TAPI版本不兼容!');
                        lineShutDown(lineApp);
                        lineApp:=0;
                      end
                 else errorcode:=lineOpen(lineApp,LINEMAPPER,@line,tapiVersion,0,0,LINECALLPRIVILEGE_NONE,LINEMEDIAMODE_INTERACTIVEVOICE,@CallParams);  // 打开线路
      if errorcode<0
        then showmessage('线路不能打开!')
        else begin      // 线路成功打开 
               lineConfigDialog(0,Self.Handle,nil); 
               lineGetIcon(0,'tapi/line',@lineIcon);
               if lineMakeCall(line,@call,PChar(TelPhone),0,@CallParams)<0
                 then showmessage('呼叫失败!')
                 else begin
                        showmessage('请摘机通话!');
                        lineHandOff(call,'µç»°²¦ºÅ³ÌÐò',LINEMEDIAMODE_INTERACTIVEVOICE);
                        lineShutDown(lineApp);
                      end;
             end;end;