نوشته شده توسط
dark-man
کسی نیست کمکم کنه ؟
دوست عزیز من KDTele رو نصب ندارم ولی خوب کدتون رو به صورت زیر تغییر دادم و یکی از Procedure ها رو به Function تبدیل کردم (البته چندتا دیگه رو هم می شد به Function تبدیل کرد).
خلاصه نتونستم به دلیل نصب نبودن KD کد رو تست کنم ولی خوب یه سری تغیراتی دادم به خصوص تعریف متغیر amPhone که سراسری بود و معلوم نبود که کی آزاد میشه !
راستی من در نوشتن DLL از داده String استفاده نمی کنم و به همین دلیل از ShareMem خبر ندارم و در این خصوص دست کاری انجام ندادم
library amDll;
uses
SysUtils,
Classes,
KDTele_TLB,
Messages,
Windows,
Forms,
UnitKDCommon,
UnitKDPhone,
ShareMem;
var
line_State : TLineState;
lineList : array [1..5] of string;
startTime, endTime : string;
// get collection of line
procedure getLine();
var
lNum : Word;
lName : WideString;
i : Integer;
amPhone : TKDPhone;
begin
try
i := 0;
amPhone := TKDPhone.Create(nil);
for lNum := 0 to amPhone.NumberOfLines do
begin
i := i + 1;
amPhone.GetLineName(lNum, lName);
if lName <> '' then
begin
lineList[i] := lName;
end;
end;
finally
FreeAndNil(amPhone);
end;
end;
// list line for developer
procedure _lineList(var lineListing : TString);
var
i : Integer;
begin
for i := 1 to 5 do
lineListing.Add(lineList[i]);
end;
// get State of Activate Line
Function lineState:String;
begin
case line_State of
lsActivated:
Result := 'خط فعال مي باشد';
lsDeactivated:
Result := 'خط فعال نيست';
lsError:
Result := 'خطا در فعال سازي خط';
else
Result:='';
end;
end;
// get Line ID and active Selected Line
procedure lineActive(lineID : Integer; var lineActiveErrorTitle : string);
var
lineActiveError : Integer;
amPhone : TKDPhone;
begin
try
amPhone := TKDPhone.Create(amPhone);
lineActiveError := amPhone.LineActive(lineID, True);
if (lineActiveError <> 0) then
begin
lineActiveErrorTitle := amPhone.GetErrorMsg(lineActiveError);
if lineActiveErrorTitle = 'The telephony device is not compatible with the value specified by the MediaMode property' then
lineActiveErrorTitle := 'مودم انتخاب شده براي برقراري تماس سازگار نيست'
else if lineActiveErrorTitle = 'Could not setup the line device' then
lineActiveErrorTitle := 'قادر به فعال سازي اين مودم نيست'
end;
finally
FreeAndNil(amPhone);
end;
end;
//procedure for dial Number
procedure dialNumber(const Number : string);
var
amPhone : TKDPhone;
begin
try
amPhone := TKDPhone.Create(amPhone);
amPhone.DialNumber(number, 0);
startTime := FormatDateTime('hh:mm:ss', Time);
finally
FreeAndNil(amPhone);
end;
end;
// procedure for hangUp Call
procedure hangUpCall();
var
amPhone : TKDPhone;
begin
try
amPhone := TKDPhone.Create(amPhone);
amPhone.Hangup;
endTime := FormatDateTime('hh:mm:ss', Time);
finally
FreeAndNil(amPhone);
end;
end;
// procedure for calculate call Time
procedure callProccess(var totalTime : string);
var
shTime, smTime, ssTime, ehTime, emTime, esTime : string;
hh, mm, ss : Integer;
begin
// start Time
shTime := Copy(startTime, 1, 2);
smTime := Copy(startTime, 4, 2);
ssTime := Copy(startTime, 7, 2);
// end Time
ehTime := Copy(endTime, 1, 2);
emTime := Copy(endTime, 4, 2);
esTime := Copy(endTime, 7, 2);
// calculate Time
hh := StrToInt(ehTime) - StrToInt(shTime);
mm := StrToInt(emTime) - StrToInt(smTime);
ss := StrToInt(esTime) - StrToInt(ssTime);
// return and show Time
totalTime := IntToStr(hh) + ':' + IntToStr(mm) + ':' + IntToStr(ss);
end;
// export important procedure
exports
callProccess, hangUpCall, dialNumber, lineActive, lineState, _lineList;
{$R *.res}
begin
end.