为什么我的这段tapi程序拨号总是出错?(200分)

  • 主题发起人 主题发起人 wzisme
  • 开始时间 开始时间
W

wzisme

Unregistered / Unconfirmed
GUEST, unregistred user!
运行后点击拨号button1总是在lineMakeCall时出现该程序执行了非法操作,即将关闭?
为什么?哪里错了??代码如下:

lineApp:HLineApp;//TAPI应用句柄
line:HLine;//线路句柄
call:HCall;//呼叫句柄

Devs:dword; //设备号

CallParams:TlineCallParams;//参数

VER:dword;//tapi version
extid:TLineExtensionID;//TAPI扩展版本号

lineIcon:PHICON;//线路设备图标



implementation

{$R *.DFM}
procedure linecallback(hdevice,dwmsg,dwcallbackinstance,dwparam1,dwparam2,dwparam3:longint);

var hcall:dword;
begin
if dwmsg=line_reply then
begin
if dwparam2<0 then messagebox(0,'呼叫响应错误处理','error',mb_ok+mb_iconerror);
end else
begin //begin-1
if dwmsg=line_callstate then
begin //begin-2
hcall:=dword(hdevice);
case dwparam1 of //begin case
linecallstate_idle: //呼叫无效处理
if hcall<>0 then
begin
linedeallocatecall(hcall);
end;

linecallstate_proceeding:messagebox(0,'呼叫正常','ok',mb_ok);
linecallstate_dialtone:messagebox(0,'检测到拨号音','ok',mb_ok);
linecallstate_dialing:messagebox(0,'正在拨号','ok',mb_ok);
linecallstate_disconnected:
begin
if dwparam2=linedisconnectmode_normal then messagebox(0,'正常断开','ok',mb_ok);
if dwparam2=linedisconnectmode_busy then messagebox(0,'线路忙','ok',mb_ok);
end;

end; //end case

end; //end-2

end; //end-1

end;

procedure TForm1.Button1Click(Sender: TObject);
begin

FillChar(CallParams, sizeof(CallParams), 0);
with CallParams do
begin
dwTotalSize := sizeof(CallParams);
dwBearerMode := LINEBEARERMODE_VOICE; //承载模式为语音
dwMediaMode := LINEMEDIAMODE_INTERACTIVEVOICE;//媒体模式为交互式语音
end;

if lineInitialize(@lineApp,HInstance,@lineCallBack,NIL,Devs)<0 then
begin
messagebox(0,'初始化线路失败','失败',mb_ok+mb_iconerror);
exit;
end;

//------------------------------如果初始化线路成功了

if Devs=0 then //无TAPI线路设备
begin
lineShutDown(lineapp);
lineApp:=0;
messagebox(0,'无TAPI线路设备','失败',mb_ok+mb_iconerror);
exit;
end;

//-------------------------------有tapi线路设备

if lineNegotiateAPIVersion(lineApp,0,$00010004,$00020000,VER,extid)<0 then
begin //TAPI版本不兼容
lineShutDown(lineApp);
lineApp:=0;
messagebox(0,'TAPI版本不兼容','失败',mb_ok+mb_iconerror);
exit;
end;

//------------------------------------- 如查TAPI版本兼容

if lineOpen(lineApp,LINEMAPPER,@line,ver,0,0,
LINECALLPRIVILEGE_NONE,LINEMEDIAMODE_INTERACTIVEVOICE,@CallParams)<0 then
begin
lineShutDown(lineApp);
lineApp:=0;
messagebox(0,'线路打开失败','失败',mb_ok+mb_iconerror);
exit;
end;

//------------------------------------- 如查线路打开成功的话

lineConfigDialog(0,Self.Handle,nil); //显示线路设备属性
lineGetIcon(0,'tapi/line',lineIcon);//lineIcon为线路设备图标句柄,可以赋值给TICON.Handle

try
lineMakeCall(line,@call,'990045',0,@CallParams);
except
lineShutDown(lineApp);
lineApp:=0;
messagebox(0,'呼叫失败','失败',mb_ok+mb_iconerror);
end;

end;
 
问题已经解决,如回复可加分
 
楼主,发给看看可以吗?谢谢!
cdyxl@163.com
 
!!
dwBearerMode := LINEBEARERMODE_VOICE; //承载模式为语音
dwMediaMode := LINEMEDIAMODE_INTERACTIVEVOICE;//媒体模式为交互式语音
你的猫支持吗?
 
接受答案了.
 
后退
顶部