Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[52.14.86.218] |
|
Сообщ.
#1
,
|
|
|
Уважаемые профи,помогите пожалуйста разобраться в чём ошибка?
суть приложения в том что оно цепляется к проге Infra call center,которая ловит звонки пользователей,и записывает в файл номер телефона... Но у меня выскакивает ошибка... Выкладываю весь код проги... unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DB, DBClient, MConnect, SConnect, ComCtrls, ADODB,ComObj, Inifiles,ToolWin, ActnMan, ActnCtrls, ActnMenus,InfraCallCenterClientFacade2_TLB ,INFRACSREMOTEPROXYLib2_TLB,ActiveX, OleCtrls,Mask; type TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; Label1: TLabel; Label2: TLabel; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } FICC:ICallCenter; FIAG:IAgent; FIFS:IAgentSession; connectionManager, connection: OleVariant; clientFacade: IUnknown; agentSession:IAgentSession; phoneSession:IAgentPhoneSession; IAPS:IAgentPhoneSessionEvents ; end; var Form1: TForm1; implementation {$R *.dfm} //------------------------------------------------------------- //процедура записи в файл procedure fileCreate(fName,str: String); var fileT: TextFile; begin DeleteFile(fName); AssignFile(fileT,fName); {$I-} Append(fileT); if IOResult<>0 then begin {$I-} Rewrite(fileT); {$I+} if IOResult<>0 then begin ShowMessage('Ошибка создания файла ' + fName); Exit; end; end; WriteLn(fileT,str); CloseFile(fileT); end; //----------------------------------------------------------------------------- //процедура определения номера procedure writeNum(pSession: IAgentPhoneSession); var phoneCall: OleVariant; phoneCalls:IPhoneCallCollection; num,i: Integer; ini:TIniFile; nOut,nLog,a,str: String; begin ini:=TiniFile.Create('...file.ini'); nout:=Ini.ReadString('FILES','out',a); nlog:=Ini.ReadString('FILES','log',a); try psession.QueryInterface(IPhoneCallCollection,phoneCalls); except exit; end; if (assigned(phoneCalls)) then begin for i:=0 to phoneCalls.Count do begin phoneCall:=phoneCalls.Item[i]; num:=phoneCall.ConnectedNumber; showmessage(inttostr(num)); if ((num<>null)and(length(intToStr(num))>0)) then begin str:=intToStr(num); phoneCall:=null; end; end; end; if (str <> null) and (length(str)>2) then begin fileCreate(nout,str); str:= DateToStr(Date) + ' ' + TimeToStr(Date) + ' ' + str; fileCreate(nlog,str); str:=null; end; end; //---------------------------------------------------------------------------- procedure TForm1.Button1Click(Sender: TObject); var username,password,csConnectionRegPath:String; phoneCalls:IPhoneCallCollection; begin username := Edit1.Text; password := Edit2.Text; csConnectionRegPath := 'Software\Infra Telesystems\Infra Communications Suite\2.30\CallCenterClientConnection'; edit1.Enabled:=false; edit2.Enabled:=false; connectionManager := CreateOleObject('INFra.ICSFacadeConnector.ConnectionManager'); try connection:=connectionManager.OpenConnection('192.168.1.80', username, 'INFRAPBX120', password); except ShowMessage('Неправильно указаны логин и/или пароль'); Exit; end; clientFacade:=connection.GetFacade('{85DF82AA-0961-4C7B-B5B8-2541DB635DC0}',0 ); clientFacade.QueryInterface(ICallCenter, FICC); FIAG := FICC.Agent as IAgent; phoneSession:=FIAG.PhoneSession as IAgentPhoneSession; ShowMessage('1'); if (not assigned(phoneSession) or not phoneSession.Opened) then begin ShowMessage('2'); FIAG.OpenPhoneSession('',PhoneSessionType_Handset,''); ShowMessage('3'); phoneSession:=FIAG.PhoneSession as IAgentPhoneSession; ShowMessage('4'); end; while (true) do begin if (phoneSession.PhoneState<>PhoneState_Idle) //вот здесь ошибка then writeNum(phoneSession); end; end; end. да, ошибка OLE error C0000096 или access violation.. это как я понял значит что объект ссылается на пустое место в памяти...но почему оно пустое?!ведь сессия создана и открыта |