?? 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);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit3,unit2;
{$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;
procedure TForm1.Button1Click(Sender: TObject);
begin
form2.Show;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -