unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls, TAPI3Lib_TLB;
type
TForm1 =
class(TForm)
Button1: TButton;
ComboBox1: TComboBox;
Button2: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure TapiEvent(ASender: TObject; TapiEvent: TAPI_EVENT;
const pEvent: IDispatch);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
objTapi: TTAPI;
addr: ITAddress;
addrs : IEnumAddress;
lwCeltFetched : Cardinal;
end;
const
TAPIMEDIATYPE_AUDIO = $8;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Request: ITRequest;
dispatch: ITDispatchMapper;
begin
Request := CoRequestMakeCall.Create;
Request.MakeCall('
555-5555','
','
','
');
end;
procedure TForm1.Button2Click(Sender: TObject);
var
iToken: HRESULT;
begin
iToken := 0;
addrs := objTapi.DefaultInterface.EnumerateAddresses;
while ( S_OK = addrs.Next(1,addr,lwCeltFetched) )
do
begin
if addr.AddressName = ComboBox1.Items[ComboBox1.ItemIndex]
then
begin
break;
end;
end;
objTapi.EventFilter := TE_CALLNOTIFICATION
or TE_CALLSTATE;
iToken := objTapi.RegisterCallNotifications(addr,true,false,TAPIMEDIATYPE_AUDIO,1);
Memo1.Lines.Clear;
end;
procedure TForm1.TapiEvent(ASender: TObject; TapiEvent: TAPI_EVENT;
const pEvent: IDispatch);
var
evntCallState: ITCallStateEvent;
callInfo: ITCallInfo;
sTelefonnummer:
String;
begin
Memo1.Lines.Add('
Fired: ' + IntToStr(TapiEvent));
case TapiEvent
of
TE_CALLNOTIFICATION:
begin
Memo1.Lines.Add('
Callnotification');
end;
TE_CALLSTATE:
begin
evntCallState := ITCallStateEvent(pEvent);
callInfo := evntCallState.Call;
case evntCallState.State
of
CS_OFFERING:
begin
sTelefonnummer := callInfo.Get_CallInfoString(CIS_CALLERIDNUMBER);
Memo1.Lines.Add('
Offering von: ' + sTelefonnummer);
end;
CS_CONNECTED:
begin
Memo1.Lines.Add('
Verbunden');
end;
CS_DISCONNECTED:
begin
Memo1.Lines.Add('
Aufgelegt');
end;
end;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
objTapi := TTAPI.Create(Self);
objTapi.Connect;
objTapi.OnEvent := TapiEvent;
addrs := objTapi.DefaultInterface.EnumerateAddresses;
ComboBox1.Items.Clear;
while ( S_OK = addrs.Next(1,addr,lwCeltFetched) )
do
begin
ComboBox1.Items.Add(addr.AddressName);
ComboBox1.ItemIndex := 0;
end;
end;
end.