Delphi call the C interface of the DLL library, parameter mismatch problem.


procedure TForm1.Button2Click(Sender: TObject);
type
TIntFunc=function(i:integer):integer;stdcall;
var
i :Integer;
Th:Thandle;
Tf:TIntFunc;
Tp:TFarProc;
Xresults:array[1..1024] of Real48;
Zresults:array[1..1024] of Real48;
measureNum:PInteger;
pageNum:PInteger;

begin
Th:=LoadLibrary('ZLDS200_TCP_DLL.dll'); {Loading DLL}
if Th>0 then
begin
try
Tp:=GetProcAddress(Th,PChar('ZLDS200GetResult'));
if Tp<>nil then
//for i := 1 to 100 do
begin
Tf:=TIntFunc(Tp);
Tf(Xresults,Zresults,measureNum,pageNum); {Call the function, 4 parameters are the parameters} {get after debugging error [error] Unit1.pas (92): Incompatible types:'Integer'and'Array'} {second: [error] Unit1.pas(92): Too many actual parameters}
for i := 1 to 1024 do
begin
Memo1.Text := Xresults[i]; {Show access to array}{[error] Unit1.pas(93): Incompatible types: 'String' and 'Real48'}
Memo2.Text := Zresults[i];
end
Memo3.Text := IntToStr(measureNum); {Display values acquired}
Memo4.Text := IntToStr(pageNum);
end
else
ShowMessage('ZLDS200GetResult function not found');
finally
FreeLibrary(Th); {The release of DLL}
end;
end
else
ShowMessage('ZLDS200_TCP_DLL.dll not found');
end;

A novice, do not know how to call, solution.

Started by Sandra at December 08, 2016 - 11:00 PM

Is not to declare the function? To display the call should not?

Posted by Sandra at December 18, 2016 - 11:06 PM