📄 unit1.~pas
字号:
unit Unit1;
//此程序是录通的示例程序,可以通过录通公司生产的硬件(话录通)方便地得到来电显示号码,拨出号码,摘挂机状态,震铃状态,可以通过声卡进行电话录音。
//基本的电话方面的开发基本都能满足。
//录通科技的联系方式是: 网址:http://www.lutongrj.com
//QQ: 718473996 [如不在线,请留言]
//联系电话: 01081812518
//email: wangtleiycp@163.com
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Inifiles, StdCtrls, ExtCtrls, Buttons;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Timer1: TTimer;
Timer2: TTimer;
EditYibo: TEdit;
Label3: TLabel;
Memo1: TMemo;
Edit2: TEdit;
Label4: TLabel;
Label5: TLabel;
ComboBox1: TComboBox;
SpeedButton1: TSpeedButton;
Label6: TLabel;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit3;
{$R *.dfm}
procedure Test(a: Integer); stdcall; //硬件回调函数
var TT: PChar;
S: string;
begin
if a = portnum then
begin
TT := LT_GetCallerID(portnum);
S := string(PChar(TT));
if Length(S) > 2 then
begin
Form1.Timer1.Enabled:= True; //可以加入你的操作
Form1.Edit1.text:= S; //'来电号码是:'
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Str: string;
inifile: tinifile;
m, j: Integer;
t: Integer;
filestr: string;
k: Integer;
i:Integer;
begin
inifile := tinifile.Create(ExtractFilePath(Application.ExeName)+ '\config.ini');
portnum := inifile.ReadInteger('DATA', 'COM', 1);
Str := inifile.ReadString('Data', 'Sampling', '1'); //灵敏度采样点
ComboBox1.ItemIndex:=strtoint(str);
SamplingChar := Str[1];
LT_SetCallbackFun(DWORD(@Test), 1);
inifile.Free;
t := 0;
k := LT_InitializeSystem(portnum, SamplingChar);//如果记录的端口号不正确,重新搜索
if (k = 0) then
begin
inifile := tinifile.Create(ExtractFilePath(Application.ExeName) + '\config.ini'); //自动搜索硬件的端口号,并且记录到文件
for i := 1 to 255 do
begin
if (LT_InitializeSystem(i, SamplingChar)) > 0 then
begin
inifile.WriteInteger('Data', 'COM', i);
portnum := i;
t := 1;
j := 0;
while (j < 255) do
begin
sleep(10);
j := j + 1;
end;
break;
end;
t := 2;
end;
inifile.Free;
end
else
begin
t := 3;
Timer2.Enabled := True; //得到硬件的震铃,摘挂机状态
end;
if (t = 2) then
begin
Application.MessageBox('您未安装和软件相配套硬件系统,'+ #13#10 +'系统仍然正常运行,但有些功能不能正常使用!'+ #13#10 +'要解决此问题请联系: 01081812518'+ #13#10 +'或登陆 www.lutongrj.com', '系统提示', MB_OK);
// Application.Terminate ;
end
else if (t = 1) then
begin
if LT_CheckSerialNo(portnum,81812518)<> 0 then showmessage('硬件正确开始启动程序!')
else begin
Application.MessageBox('您未安装和软件相配套硬件系统,系统退出!'+ #13#10 +'要解决此问题请联系: 01081812518'+ #13#10 +'或登陆 www.lutongrj.com', '系统提示', MB_OK);
Application.Terminate ;
end;
end
else
begin
if LT_CheckSerialNo(portnum,81812518)= 0 then begin
Application.MessageBox('您未安装和软件相配套硬件系统,系统退出!'+ #13#10 +'要解决此问题请联系: 01081812518'+ #13#10 +'或登陆 www.lutongrj.com', '系统提示', MB_OK);
Application.Terminate ; end;
end;
showmessage('已经启动来电收号!');
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
// showmessage('来电话了!');
Timer1.Enabled:=False;
end;
procedure TForm1.Timer2Timer(Sender: TObject);//得到硬件的震铃,摘挂机状态
var
port:integer;
state,a,xianshi,b:integer;
s,temp,outnum: string;
t,i:integer;
Str:string;
begin
for port := 0 to 7 do
begin
GetKHTState(port, state);
if (state and $F) <> 0 then
begin
if (state and $1)<>0 then
begin
temp:='1';
end
else
temp:='0';
s := s +' 来电=' + temp;
if (state and $2)<>0 then
begin
temp:='1';
end
else
temp:='0';
s := s + ' 振铃=' + temp;
if (state and $4)<>0 then
begin
temp:='1';
end
else
temp:='0';
s := s + ' 错误=' + temp;
if (state and $8)<>0 then
begin
temp := '1' ;
if (state and $F0)/16<10 then //判断拨出字符
outnum:= FloatToStr((state and $F0)/16)
else if (state and $F0)/16=10 then
outnum:='0'
else if (state and $F0)/16=11 then
outnum:='*'
else if (state and $F0)/16=12 then
outnum:='#'
else
outnum:='' ;
EditYibo.Text:=EditYibo.Text+outnum;
end
else
temp := '0';
s := s+' dtmf=' + temp ;
s := s+' Dtmf=' + FloatToStr((state and $F0)/16);
Memo1.Lines.Add(s);
end;
try
if (portnum - 64) = port then
begin
if (state and $1000) <> 0 then //挂机
begin
Edit2.Text := '挂机' ;
EditYibo.Text:='';
end
else
begin
Edit2.Text := '摘机';
end;
end;
except
end;
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
LT_TelHookOnOff(portnum,#0);//挂机
LT_CloseSystem(portnum); //关闭话录通硬件
Application.Terminate();
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
IniFile:Tinifile;
i:integer;
str:string;
begin
IniFile:=Tinifile.Create( ExtractFilePath(Application.ExeName)+'\config.ini');
str:=inttostr(Combobox1.ItemIndex);
SamplingChar:=str[1];
IniFile.WriteString('Data','Sampling',str);
LT_CloseSystem(portnum);
sleep(1000);
if LT_InitializeSystem(portnum,SamplingChar)=1 then
showmessage('设置成功!')
else
showmessage('对不起,您的端口打开有误');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -