Subversion Repositories calllib

Rev

Rev 2 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 5
Line 26... Line 26...
26
 
26
 
27
implementation
27
implementation
28
 
28
 
29
{$R *.dfm}
29
{$R *.dfm}
30
 
30
 
-
 
31
const
-
 
32
  {$IFDEF WIN64}
-
 
33
  makecalldll = 'MakeCall.64.dll';
-
 
34
  {$ELSE}
-
 
35
  makecalldll = 'MakeCall.32.dll';
-
 
36
  {$ENDIF}
-
 
37
 
-
 
38
{$IFDEF UNICODE}
-
 
39
function GetTapiDevices(buf: PWideChar): integer; stdcall; external makecalldll name 'GetTapiDevicesW';
-
 
40
function MakeCall(phoneNumber: PWideChar; deviceId: integer): integer; stdcall; external makecalldll name 'MakeCallW';
-
 
41
{$ELSE}
31
function GetTapiDevices(buf: PAnsiChar): integer; stdcall; external 'MakeCall.dll';
42
function GetTapiDevices(buf: PAnsiChar): integer; stdcall; external makecalldll name 'GetTapiDevicesA';
32
function MakeCall(phoneNumber: PAnsiChar; deviceId: integer): integer; stdcall; external 'MakeCall.dll';
43
function MakeCall(phoneNumber: PAnsiChar; deviceId: integer): integer; stdcall; external makecalldll name 'MakeCallA';
-
 
44
{$ENDIF}
33
 
45
 
34
type
-
 
35
  TAnsiCharArray = array of AnsiChar;
-
 
36
 
46
 
37
function ArrayToString(const a: TAnsiCharArray): string;
47
function ArrayToString(const a: TCharArray): string;
38
begin
48
begin
39
  if Length(a)>0 then
49
  if Length(a)>0 then
40
    SetString(Result, PChar(@a[0]), Length(a))
50
    SetString(Result, PChar(@a[0]), Length(a))
41
  else
51
  else
42
    Result := '';
52
    Result := '';
43
end;
53
end;
44
 
54
 
45
procedure TForm1.CallBtnClick(Sender: TObject);
55
procedure TForm1.CallBtnClick(Sender: TObject);
46
var
56
var
47
  s: AnsiString;
57
  s: String;
48
begin
58
begin
49
  s := PhoneNumberEdit.Text;
59
  s := PhoneNumberEdit.Text;
50
  MakeCall(PAnsiChar(s), DeviceListBox.ItemIndex);
60
  MakeCall(PChar(s), DeviceListBox.ItemIndex);
51
end;
61
end;
52
 
62
 
53
procedure TForm1.FormShow(Sender: TObject);
63
procedure TForm1.FormShow(Sender: TObject);
54
begin
64
begin
55
  ListDevices;
65
  ListDevices;
Line 66... Line 76...
66
end;
76
end;
67
 
77
 
68
procedure TForm1.ListDevices;
78
procedure TForm1.ListDevices;
69
var
79
var
70
  len: integer;
80
  len: integer;
71
  buf: TAnsiCharArray;
81
  buf: TCharArray;
72
begin
82
begin
73
  len := GetTapiDevices(nil);
83
  len := GetTapiDevices(nil);
74
  SetLength(buf, len+1);
84
  SetLength(buf, len+1);
75
  GetTapiDevices(PAnsiChar(buf));
85
  GetTapiDevices(PChar(buf));
76
  DeviceListBox.Items.Text := ArrayToString(buf);
86
  DeviceListBox.Items.Text := ArrayToString(buf);
77
end;
87
end;
78
 
88
 
79
end.
89
end.